Current course:

PHP Arrays


What is an array?

An array is like a box to store items in. You can store one or many items, and retrieve them later.

How do you create an array?
$names = array("Frank", "Bill", "John", "Dave");

How to you use the data in an array?
$name = $names[0]; //Frank

How do you determine the number of items in an array?
$itemsInMyArray = count($myArray); //4

How would you retrieve a random name from your array?

foreach is used to loop through each item in your array - more details coming soon.