PHP 5 Array Functions
PHP Array Introduction
PHP Array functions allow you to access and manipulate arrays.
Both simple and multi-dimensional arrays are supported.
Installation
PHP Array functions are part of the PHP core. No installation is required to use these functions.
PHP 5 Array Functions
| Function | Description | 
|---|---|
| array() | Creates an array. | 
| array_change_key_case() | Returns an array with all keys in lowercase or uppercase. | 
| array_chunk() | Splits an array into new array chunks. | 
| array_column() | Returns the values from a single column in the input array. | 
| array_combine() | Creates a new array by merging two arrays (one as key names, one as key values). | 
| array_count_values() | Counts all the values of an array. | 
| array_diff() | Compares arrays and returns the differences (compares only values). | 
| array_diff_assoc() | Compares arrays and returns the differences (compares keys and values). | 
| array_diff_key() | Compares arrays and returns the differences (compares only keys). | 
| array_diff_uassoc() | Compares arrays and returns the differences (compares keys and values, using a user-defined key comparison function). | 
| array_diff_ukey() | Compares arrays and returns the differences (compares only keys, using a user-defined key comparison function). | 
| array_fill() | Fills an array with values. | 
| array_fill_keys() | Fills an array with values, specifying keys. | 
| array_filter() | Filters elements of an array using a callback function. | 
| array_flip() | Exchanges all keys with their associated values in an array. | 
| array_intersect() | Compares arrays and returns the intersections (compares only values). | 
| array_intersect_assoc() | Compares arrays and returns the intersections (compares keys and values). | 
| array_intersect_key() | Compares arrays and returns the intersections (compares only keys). | 
| array_intersect_uassoc() | Compares arrays and returns the intersections (compares keys and values, using a user-defined key comparison function). | 
| array_intersect_ukey() | Compares arrays and returns the intersections (compares only keys, using a user-defined key comparison function). | 
| array_key_exists() | Checks if the specified key exists in the array. | 
| array_key_first() | Gets the first key of an array. | 
| array_key_last() | Gets the last key of an array. | 
| array_keys() | Returns all the keys of an array. | 
| array_map() | Applies a user-defined function to each value of an array and returns a new array. | 
| array_merge() | Merges one or more arrays into one array. | 
| array_merge_recursive() | Merges one or more arrays into one array recursively. | 
| array_multisort() | Sorts multiple or multi-dimensional arrays. | 
| array_pad() | Inserts a specified number of elements, with a specified value, to an array. | 
| array_pop() | Deletes the last element of an array (pop). | 
| array_product() | Calculates the product of the values in an array. | 
| array_push() | Inserts one or more elements to the end of an array (push). | 
| array_rand() | Picks one or more random entries out of an array, and returns the key(s) of the random entries. | 
| array_reduce() | Iteratively reduces the array to a single value using a user-defined function, and returns it. | 
| array_replace() | Replaces the values of the first array with the values from following arrays. | 
| array_replace_recursive() | Replaces the values of the first array with the values from following arrays recursively. | 
| array_reverse() | Returns an array with elements in reverse order. | 
| array_search() | Searches the array for a given value and returns the corresponding key if successful. | 
| array_shift() | Removes the first element from an array, and returns the value of the removed element. | 
| array_slice() | Returns the selected parts of an array. | 
| array_splice() | Removes elements from an array and replaces them with new elements. | 
| array_sum() | Returns the sum of the values in an array. | 
| array_udiff() | Compares arrays and returns the differences (only compares values, using a user-defined key comparison function). | 
| array_udiff_assoc() | Compares arrays and returns the differences (compares keys and values, using built-in functions for key comparison and a user-defined function for value comparison). | 
| array_udiff_uassoc() | Compares arrays and returns the differences (compares keys and values, using two user-defined key comparison functions). | 
| array_uintersect() | Compares arrays and returns the intersections (only compares values, using a user-defined key comparison function). | 
| array_uintersect_assoc() | Compares arrays and returns the intersections (compares keys and values, using built-in functions for key comparison and a user-defined function for value comparison). | 
| array_uintersect_uassoc() | Compares arrays and returns the intersections (compares keys and values, using two user-defined key comparison functions). | 
| array_unique() | Removes duplicate values from an array. | 
| array_unshift() | Inserts new elements at the beginning of an array. | 
| array_values() | Returns all the values of an array. | 
| array_walk() | Applies a user function to every member of an array. | 
| array_walk_recursive() | Recursively apply a user function to every member of an array. | 
| arsort() | Sort an associative array in descending order by value. | 
| asort() | Sort an associative array in ascending order by value. | 
| compact() | Create an array containing variables and their values. | 
| count() | Return the number of elements in an array. | 
| current() | Return the current element in an array. | 
| each() | Return the current key/value pair in an array. | 
| end() | Set the internal pointer of an array to its last element. | 
| extract() | Import variables from an array into the current symbol table. | 
| in_array() | Check if a specified value exists in an array. | 
| key() | Fetch a key from an associative array. | 
| krsort() | Sort an associative array by key in descending order. | 
| ksort() | Sort an associative array by key in ascending order. | 
| list() | Assign variables as if they were an array. | 
| natcasesort() | Sort an array using a case-insensitive "natural order" algorithm. | 
| natsort() | Sort an array using a "natural order" algorithm. | 
| next() | Advance the internal pointer of an array. | 
| pos() | Alias of current(). | 
| prev() | Rewind the internal pointer of an array. | 
| range() | Create an array containing a range of elements. | 
| reset() | Set the internal pointer of an array to its first element. | 
| rsort() | Sort an indexed array in descending order. | 
| shuffle() | Shuffle the elements of an array in random order. | 
| sizeof() | Alias of count(). | 
| sort() | Sort an indexed array in ascending order. | 
| uasort() | Sort an array by values using a user-defined comparison function. | 
| uksort() | Sort an array by keys using a user-defined comparison function. | 
| usort() | Sort an array using a user-defined comparison function. |