PHP - Array
An arrays is group of elements given one name. An array is a special variable, which can hold more than one value at a time.
- An array named Days could contain the days of the week
- Arrays start counting with element zero (not one)
- An array is another data type--it is a collection of data that is given one name. An array is made up of a group of elements, which may either numbers or character strings. Each Element has a key and a value indicated by key=>value
- An array is arranged so that each item in the array can be located by using the key when needed.
- If you have a list of items (a list of car names, for example), storing the cars in single variables
Example:
<?php
$cars = array("Volvo","BMW","Toyota");
echo "I like ".$cars[0].", ".$cars[1]." and ".$cars[2].".";
?>
Output:
I like Volvo, BMW and Toyota.