PHP Array Functions
- Previous Page AJAX Poll
- Next Page PHP Calendar
PHP Array Introduction
Array functions allow you to access and manipulate arrays.
Supports one-dimensional and multidimensional arrays.
Installation
Array functions are part of the PHP core and can be used without installation.
PHP 5 Array Functions
Function | Description |
---|---|
array() | Create an array. |
array_change_key_case() | Change all keys in the array to lowercase or uppercase. |
array_chunk() | Split an array into new array chunks. |
array_column() | Return the values of a single column from the input array. |
array_combine() | Create a new array by merging two arrays. |
array_count_values() | Used to count the number of times all values appear in the array. |
array_diff() | Compare arrays, return the difference set (only compare key values). |
array_diff_assoc() | Compare arrays, return the difference set (compare key names and key values). |
array_diff_key() | Compare arrays, return the difference set (only compare key names). |
array_diff_uassoc() | Compare arrays, return the difference set (compare key names and key values, using a user-defined key name comparison function). |
array_diff_ukey() | Compare arrays, return the difference set (only compare key names, using a user-defined key name comparison function). |
array_fill() | Fill the array with given key values. |
array_fill_keys() | Fill the array with specified key names and given key values. |
array_filter() | Filter elements in the array using a callback function. |
array_flip() | Swap the keys and values in the array. |
array_intersect() | Compare arrays, return the intersection (only compare key values). |
array_intersect_assoc() | Compare arrays, return the intersection (compare key names and key values). |
array_intersect_key() | Compare arrays, return the intersection (only compare key names). |
array_intersect_uassoc() | Compare arrays, return the intersection (compare key names and key values, using a user-defined key name comparison function). |
array_intersect_ukey() | Compare arrays, return the intersection (only compare key names, using a user-defined key name comparison function). |
array_key_exists() | Check if the specified key name exists in the array. |
array_keys() | Return all the key names in the array. |
array_map() | Send each value in the array to a user-defined function and return the new value. |
array_merge() | Merge one or more arrays into one array. |
array_merge_recursive() | Recursively merge one or more arrays. |
array_multisort() | Sort multiple arrays or multidimensional arrays. |
array_pad() | Fill the array to the specified length with values. |
array_pop() | Delete the last element of the array (pop). |
array_product() | Calculate the product of all values in the array. |
array_push() | Insert one or more elements at the end of the array (push). |
array_rand() | Return one or more random keys from the array. |
array_reduce() | Return an array as a string using a user-defined function. |
array_replace() | Replace the values of the first array with the values of the subsequent array. |
array_replace_recursive() | Recursively use the values of the subsequent array to replace the values of the first array. |
array_reverse() | Return the array in reverse order. |
array_search() | Search for a given value in the array and return the key name. |
array_shift() | Delete the first element of the array and return the value of the deleted element. |
array_slice() | Return the selected part of the array. |
array_splice() | Delete and replace the specified element in the array. |
array_sum() | Return the sum of the values in the array. |
array_udiff() | Compare arrays and return the difference set (compare values only using a user-defined key comparison function). |
array_udiff_assoc() | Compare arrays and return the difference set (compare keys and values using built-in functions to compare key names, and user-defined functions to compare key values). |
array_udiff_uassoc() | Compare arrays and return the difference set (compare keys and values using two user-defined key comparison functions). |
array_uintersect() | Compare arrays and return the intersection (compare values only using a user-defined key comparison function). |
array_uintersect_assoc() | Compare arrays and return the intersection (compare keys and values using built-in functions to compare key names, and user-defined functions to compare key values). |
array_uintersect_uassoc() | Compare arrays and return the intersection (compare keys and values using two user-defined key comparison functions). |
array_unique() | Remove duplicate values from the array. |
array_unshift() | Insert one or more elements at the beginning of the array. |
array_values() | Return all values in the array. |
array_walk() | Apply a user function to each member of the array. |
array_walk_recursive() | Apply a user function recursively to each member of the array. |
arsort() | Sort the associated array in descending order by key value. |
asort() | Sort the associated array in ascending order by key value. |
compact() | Create an array containing variable names and their values. |
count() | Return the number of elements in the array. |
current() | Return the current element in the array. |
each() | Return the current key/value pair in the array. |
end() | Point the internal pointer of the array to the last element. |
extract() | Import variables from the array into the current symbol table. |
in_array() | Check if a specified value exists in the array. |
key() | Get keys from associative arrays. |
krsort() | Reverse sort arrays by key name. |
ksort() | Sort arrays by key name. |
list() | Assign values from the array to some variables. |
natcasesort() | Sort arrays using the 'natural sorting' algorithm, case-insensitive. |
natsort() | Sort arrays using the 'natural sorting' algorithm. |
next() | Move the internal pointer of the array forward one position. |
pos() | Alias of current(). |
prev() | Move the internal pointer of the array back one position. |
range() | Create an array containing specified range units. |
reset() | Point the internal pointer of the array to the first element. |
rsort() | Reverse sort arrays. |
shuffle() | Shuffle arrays. |
sizeof() | Alias of count(). |
sort() | Sort arrays. |
uasort() | Sort array values using user-defined comparison functions. |
uksort() | Sort array keys using user-defined comparison functions. |
usort() | Sort arrays using user-defined comparison functions. |
- Previous Page AJAX Poll
- Next Page PHP Calendar