The PHP Array function allows you to access and manipulate arrays.
Supports simple arrays and multidimensional arrays.
The PHP Array function is an integral part of PHP core. No installation is required to use these functions.
function | describe |
---|---|
array() | Create an array. |
array_change_key_case() | Returns an array whose keys are all uppercase or lowercase. |
array_chunk() | Split an array into new array chunks. |
array_column() | Returns the value of a single column in the input array. |
array_combine() | Create a new array by merging two arrays (one with keys and one with keys). |
array_count_values() | Used to count the number of occurrences of all values in an array. |
array_diff() | Compares arrays and returns the difference between two arrays (only comparing key values). |
array_diff_assoc() | Compare arrays and return the difference between two arrays (compare key names and key values). |
array_diff_key() | Compares arrays and returns the difference between two arrays (only keys are compared). |
array_diff_uassoc() | Compare arrays and return the difference between the two arrays (comparing key names and key values, using a user-defined key comparison function). |
array_diff_ukey() | Compare arrays and return the difference between the two arrays (only compare key names, using user-defined key comparison function). |
array_fill() | Fills the array with the given key values. |
array_fill_keys() | Fills the array with the given key value. |
array_filter() | Use a callback function to filter elements in an array. |
array_flip() | Reverse/swap the key names in the array and the corresponding associated key values. |
array_intersect() | Compares arrays and returns the intersection of two arrays (only comparing key values). |
array_intersect_assoc() | Compares arrays and returns the intersection of two arrays (compares key names and key values). |
array_intersect_key() | Compares arrays and returns the intersection of two arrays (only keys are compared). |
array_intersect_uassoc() | Compare arrays and return the intersection of the two arrays (comparing keys and key values, using user-defined key comparison functions). |
array_intersect_ukey() | Compare arrays and return the intersection of two arrays (only compare keys, using user-defined key comparison function). |
array_key_exists() | Checks whether the specified key exists in the array. |
array_keys() | Returns all keys in the array. |
array_map() | Applies a user-defined function to each value in the given array and returns a new value. |
array_merge() | Combine one or more arrays into a single array. |
array_merge_recursive() | Recursively combine one or more arrays into a single array. |
array_multisort() | Sort multiple arrays or multidimensional arrays. |
array_pad() | Inserts a specified number of elements with a specified value into an array. |
array_pop() | Remove the last element from the array (pop it off the stack). |
array_product() | Calculate the product of all values in an array. |
array_push() | Insert (push) one or more elements to the end of the array. |
array_rand() | Randomly select one or more elements from the array and return the key name. |
array_reduce() | By using a user-defined function, iteratively reduces the array to a string and returns it. |
array_replace() | Replaces the values of the first array with the values of the following array. |
array_replace_recursive() | Recursively replaces the values of the first array with the values of subsequent arrays. |
array_reverse() | Reverse the order of elements in the original array, create a new array and return it. |
array_search() | Searches the array for a given value and returns the corresponding key if successful. |
array_shift() | Removes the first element from the array and returns the value of the removed element. |
array_slice() | Returns the selected portion of an array. |
array_splice() | Removes specified elements from an array and replaces them with other values. |
array_sum() | Returns the sum of all values in the array. |
array_udiff() | Compare arrays and return the difference between the two arrays (only compare key values, using a user-defined key comparison function). |
array_udiff_assoc() | Compare arrays and return the difference between two arrays (compare key names and key values, use built-in functions to compare key names, use user-defined functions to compare key values). |
array_udiff_uassoc() | Compare arrays and return the difference between two arrays (to compare keys and key values, use two user-defined key comparison functions). |
array_intersect() | Compares arrays and returns the intersection of two arrays (only compares key values, using a user-defined key comparison function). |
array_uintersect_assoc() | Compare arrays and return the intersection of two arrays (compare key names and key values, use built-in functions to compare key names, use user-defined functions to compare key values). |
array_uintersect_uassoc() | Compare arrays and return the intersection of two arrays (comparing keys and key values, using two user-defined key comparison functions). |
array_unique() | Remove duplicate values from an array. |
array_unshift() | Insert one or more elements at the beginning of the array. |
array_values() | Returns all values in the array. |
array_walk() | Applies a user function to each member of the array. |
array_walk_recursive() | Applies the user function recursively to each member of the array. |
arsort() | Sort an associative array in descending order by key value. |
asort() | Sort an associative array in ascending order by key value. |
compact() | Create an array containing variable names and their values. |
count() | Returns the number of elements in the array. |
current() | Returns the current element in the array. |
each() | Returns the current key/value pair in the array. |
end() | Sets the array's internal pointer to the last element. |
extract() | Import variables from an array into the current symbol table. |
in_array() | Checks whether the specified value exists in the array. |
key() | Get the key name from the associative array. |
krsort() | Sort an associative array in descending order by key name. |
ksort() | Sort the associative array in ascending order by key name. |
list() | Assign the values in the array to some array variables. |
natcasesort() | Sort an array in a case-insensitive way using the "natural sort" algorithm. |
natsort() | Sort the array using the "natural sorting" algorithm. |
next() | Moves the internal pointer in the array backward one position. |
pos() | Alias for current(). |
prev() | Back the internal pointer of the array one bit. |
range() | Creates an array containing a specified range of elements. |
reset() | Set the array's internal pointer to the first element. |
rsort() | Sort a numeric array in descending order. |
shuffle() | Rearrange the elements in the array in random order. |
sizeof() | Alias for count(). |
sort() | Sort a numeric array in ascending order. |
uasort() | Sort key values in an array using a user-defined comparison function. |
uksort() | Sort keys in an array using a user-defined comparison function. |
usort() | Sort an array using a user-defined comparison function. |