An array in PHP is actually an ordered map. A map is a type that maps values to keys. This type is optimized in several ways, so you can use it as a real array, or a list (vector), hashtable (which is an implementation of a map), dictionary, collection, stack, queue and probably more. Because you can have another PHP array as a value, you can also quite easily simulate trees.
There are three different kind of arrays:
A numeric array stores each array element with a numeric index (ID Key).
There are different ways to create a numeric array.
1. In the following example the index are automatically assigned (the index starts at 0):
2. In the following example we assign the index manually:
PHP Example:-Use of ID key
In an associative array a key is associated with a value. If you wanted to store the prize of your products in an array, a numerically indexed array would not be the best choice. Instead, we could use the products names as the keys in our associative array, and the value would be their respective prize.PHP Example:-
As each element value of the array can be any type it means that it can be other array as well. If an array element value is an other array then this is a multidimensional array. Of course the internal array values can be arrays as well and so on. You can define 10 dimensional (or more) array if you want.
PHP Example :-
We create a multidimensional array, with automatically assigned ID keys:
?Computer Science is no more about computers than astronomy is about telescopes.
?Computers must be male. As soon as you commit to one you realize that if you had waited a little longer, you could have obtained a better model. In order to get their attention, you have to turn them on. Big power surges knock them out for the rest of th