5.1. Single-Dimensional Arrays
To refer to an element of an array, you use square brackets. Inside the brackets you put the index of the element, as in Listing 5.1. This construct may be treated exactly like a variable. You may assign a value or pass its value to a function. You do not have to declare anything about the array before you use it. Like variables, any element of an array will be created on the fly. If you refer to an array element that does not exist, it will evaluate to be zero or an empty string depending on the context.
Listing 5.1. Referencing array elements
<?php $Cities = "San Francisco"; $Cities = "Los Angeles"; $Cities = "New York"; $Cities = "Martinez"; print("I live in $Cities.<br>\n"); ?>