A PHP array

A PHP array

An array is a special variable or multipel data container object. Unlike a variable holding just one value, an array can hold multiple values in a single type array container. All elements in an array have numeric index which is used to acces their element value.

first index second third fourth fifth sixth seventh last index
0 1 2 3 4 5 6 7 indices/keys
“zero” “one” “two” “three” “four” “five” “six” “seven” elements/values
Eg

Summary

Allocate memory for the elements in the array variable:

it will print out the value of index 1.

Array of Arrays

Array of arrays or so called multidimensional array. An array which is, its components are arrays. An element should be accessed by a corresponding number of indexes

Eg

Output:

Summary

Here we have declared and assigned the multidimensional array type in order to access its corresponding values as an index value.

Leave a Reply

Your email address will not be published. Required fields are marked *