| Code | Description | Output |
|---|---|---|
| $states = array("AZ", "CA", "IL", "IN", "NY"); | Initializes an array with five elements | |
| echo count($states); | Displays the number of elements in the array | 5 |
foreach ($states as $state) {
echo $state . ", ";
}
|
Loops through an array and displays all values | AZ, CA, IL, IN, NY, |
| $states[] = "NM"; | Adds one more element to the list | AZ, CA, IL, IN, NY, NM, |