Chapter 3. Using Arrays
Create an Array
Arrays are complex variables that store a group of values under a single variable name. You can use an array to store related values that you want to process as a group. Each value in an array is called an element. An array can have as many elements as needed. You do not need to specify the size of an array. PHP will store the array with as many elements as you assign to it.
Each element in an array has a key so that you can access the individual elements. You assign values to an array as follows:
$arrayname['key1'] = value1; $arrayname['key2'] = value2;
You can use numbers or strings as keys. String keys should be enclosed in single quotes, such as $arrayname['cost']
. If you do not include a key in the square ...
Get PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.