Tutorial PHP Arrays

An array stores multiple values in one single variable:

echo “I like ” . $cars[0] . “, ” . $cars[1] . ” and ” . $cars[2] . “.”;

What is an Array?

An array is a special variable, which can hold more than one value at a time.

If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this:


Create an Array in PHP

In PHP, the array() function is used to create an array:


Get The Length of an Array – The count() Function

echo count($cars);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s