O'Reilly logo

ColdFusion 9 Developer Tutorial by John Farrar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding arrays

The array is an interesting variable construct. You can think of an array as a collection of commonly named variables with a numeric index. We will take the last code example and transfer it to arrays. Here we will change the backend in major ways, but the frontend will run completely the same from a user's point of view. If you look closer, you will be able to see that we are now passing a variable from page to page rather than the whole questions as before. Let's check out the code:

<!--- Example: 1_18.cfm ---> <!--- Processing ---> <cfparam name="url.question" default="1"> <cfscript> question = arrayNew(1); question[1] = "What is the speed limit?"; question[2] = "What is a car?"; question[3] = "How much is gas?"; answer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required