PHP Arrays

December 8, 2016 by pranjal

Filed under php

Last modified December 8, 2016

An array is a data structure that stores one or more similar type of values in a single value. For example if you want to store 100 numbers then instead of defining 100 variables its easy to define an array of 100 length.
There are three different kind of arrays and each array value is accessed using an ID c which is called array index.

Numeric array − An array with a numeric index. Values are stored and accessed in linear fashion. These arrays can store numbers, strings and any object but their index will be represented by numbers. By default array index starts from zero.

Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order. The associative arrays are very similar to numeric arrays in term of functionality but they are different in terms of their index. Associative array will have their index as string so that you can establish a strong association between key and values.

Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices. A multi-dimensional array each element in the main array can also be an array. And each element in the sub-array can be an array, and so on. Values in the multi-dimensional array are accessed using multiple index.

Leave a Comment