An Array can be thought of as a single variable that stores more than one value.
An array uses a key to determine what value to reference. So,
$array[key] = value;
Key values start at “0” normally, as PHP likes to number things starting at Zero instead of One.
It’s a programming thing, I don’t know either.
Let’s use our truck examples from above, and assign then in an array.
<?php
$truck_array[0] = "Toyota";
$truck_array[1] = "Dodge";
$truck_array[2] = "Chevy";
$truck_array[3] = "Ford";
?>
And here’s how we could output information from the array:
<?php
echo "Two great truck makers are " .
$truck_array[0] . " & " .
$truck_array[1];
echo "<br />Two more great truck makers are " .
$truck_array[2] . " & " .
$truck_array[3];
?>
Here’s is the output result of the above array:
0 Comments
Leave a Reply. |
David Rentson
If this free PHP and MYSQL Tutorial is helpful for you... Great! Archives
October 2008
Categories
All
|