Types of Arrays?

There are three types of arrays in PHP:

<strong>Index Array:</strong>-
Those arrays which have key value as a numeric i.e. arrays with numeric index.
e.g.
Array (
[0] => Praful
[1] => Parul
[2] => Pranav
)

<strong>Associative arrays:</strong>-
Those arrays which key have named value i.e. arrays with named keys.
i.e.
Array (
[fname] => Praful
[lname] => Kumar
[Title] => Mr.
)

<strong>Multidimensional arrays:</strong>-
Arrays containing one or more arrays. An array can also contain another array as a value, which in turn can hold other arrays as well. In such a way we can create two- or three-dimensional arrays.

An example of Multidimensional array is as follows:
Array (
[Name] => Array (
[0] => Praful
[1] => Parul
[2] => Pranav
)
[Address] => Array (
[0] => New Delhi
[1] => Gurgaon
[2] => Kolkata
)
)

Posted in PHP | Tagged , , , , | Comments Off

Comments are closed.