An array is a special variable, which can hold more than one value at a time. There are three different kind of arrays and each array value is accessed using an ID which is called array index.
Types of Arrays:
1D Array / Numeric array.
Single Dimensional array is a array with a numeric index. Values are stored and accessed in linear fashion.Example 1.1: Single Dimensional Array. Example 1.2: Display all Array values using Foreach Loop. Example 1.3: Display all color values in array using Foreach Loop.
Count and sizeof function is use to calculate array length. Its Syntax is: echo sizeof($web); echo count($web);
The associative arrays are very similar to numeric arrays in term of functionality but they are different in terms of their index number. Associative array will have their index as string so that you can establish a strong association between key and values.Example 2: Associative array
Multidimensional array containing one or more arrays and values are accessed using multiple indexes.Example 3: Multidimensional array. Display 3 Student marks.
Note: Get The Length of an Array - The count() Function: echo count($marks);
|sort()||Sort arrays in ascending order. Syntax: sort($array);|
|rsort()||Sort arrays in descending order|
|asort()||Sort associative arrays in ascending order, according to the value|
|ksort()||Sort associative arrays in ascending order, according to the key|
|arsort()||Sort associative arrays in descending order, according to the value|
|krsort()||Sort associative arrays in descending order, according to the key|