For this tutorial it is recommended you have access to a PHP host.
Arrays can be used to store multiple pieces of information in just 1 variable. Here is an example array
$colors = array('blue','red','green','black');
That is an array, now to call the information, we could
echo $colors[0];
That would output Blue (Remember PHP starts counting at 0, not 1!)
If you wanted to display a random color from the array you could use,
$randy = rand(0,3); echo $colors[$randy];
You could even use a Loop, to display all the colors, but Loops will be left for another tutorial.
Now you should have a basic idea of how to use an Array, and how to display it.
Comments
Post new comment