PHP array functions allow you to interact with and manipulate arrays in various ways. Arrays are essential for storing, managing, and operating on sets of variables.
The array functions are part of the PHP core. There is no installation needed to use these functions.
Function | Description |
---|---|
array() | Create an array |
array_change_key_case() | array to lowercase or uppercase |
array_chunk() | Splits an array into inside of arrays |
array_column() | Specific column find into array |
array_combine() | “keys” array and one “values” array combine single array |
array_count_values() | Count all the values of array |
array_diff() | Find a two array in different values |
array_diff_assoc() | Compare the keys and values of two arrays, and return the differences |
array_diff_key() | Compare the keys of two arrays, and return the differences |
array_diff_uassoc() | Compare keys and values, using a user-defined key |
array_diff_ukey() | Compare keys only, using a user-defined key |
array_fill() | Fills an array with values |
array_fill_keys() | Fills an array with values, specifying keys |
array_filter() | Filter the values of an array |
array_flip() | Create value to key of an array |
array_intersect() | Compares the values of two (or more) arrays, and returns the matches (compare values only) |
array_intersect_assoc() | compare keys and values returns the matches |
array_intersect_key() | compare keys only returns the matches |
array_intersect_uassoc() | compare keys and values, using a user-defined key returns the matches |
array_intersect_ukey() | compare keys only, using a user-defined key returns the matches |
array_key_exists() | Checks if the specified key exists in the array |
array_keys() | Return of the key in the array |
array_map() | Return an array with the new values |
array_merge() | Merge two array and create signle array |
array_merge_recursive() | Merge two array and create signle array with create another inside array |
array_multisort() | Returns a sorted array |
array_pad() | Inserts a specified number of items, with a specified value, to an array |
array_pop() | Delete the last element of an array |
array_product() | Calculates the product of the values in an array |
array_push() | Inserts one or more elements to the end of an array |
array_rand() | Returns one or more random keys from an array |
array_reduce() | Returns an array as a string |
array_replace() | Replaces the values of the first array with the values from following arrays |
array_replace_recursive() | Array inside array replace |
array_reverse() | Returns an array in the reverse order |
array_search() | Search specific value and return the key |
array_shift() | Removes the first element from an array, and returns the value of the removed element |
array_slice() | Return the specific part of an array |
array_splice() | Removes and replaces specified elements of an array |
array_sum() | Return the sum of values of an array |
array_udiff() | Compare arrays, and returns the differences |
array_udiff_assoc() | Compare keys and values returns the differences |
array_udiff_uassoc() | Compare keys and values, using two user-defined key comparison functions and returns the differences |
array_uintersect() | Compare arrays, and returns the matches |
array_uintersect_assoc() | compare keys and values returns the matches |
array_uintersect_uassoc() | Compare arrays, and returns the matches (compare keys and values, using two user-defined key comparison functions) |
array_unique() | Removes duplicate value from an array |
array_unshift() | Adds one or more elements to 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() | Applies a user function key and value to every member of an array |
arsort() | Sorts an associative array in descending order, according to the value |
asort() | Sorts an associative array in ascending order, according to the value |
compact() | Create array containing variables and their values |
count() | Returns the number of elements in an array |
current() | Returns the current element in an array |
each() | Returns the current key and value pair from an array |
end() | Sets the internal pointer of an array to its last element |
extract() | Imports variables into the current symbol table from an array |
in_array() | Checks if a specified value exists in an array |
key() | Fetches a key from an array |
krsort() | Sorts an associative array in descending order, according to the key |
ksort() | Sorts an associative array in ascending order, according to the key |
list() | Assigns variables as if they were an array |
natcasesort() | Sorts an array using a case insensitive “natural order” algorithm |
natsort() | Sorts an array using a “natural order” algorithm |
next() | Advance the internal array pointer of an array |
pos() | Alias of current() |
prev() | Rewinds the internal array pointer |
range() | Creates an array containing a range of elements |
reset() | Sets the internal pointer of an array to its first element |
rsort() | Sorts an indexed array in descending order |
shuffle() | Shuffles an array |
sizeof() | Alias of count() |
sort() | Sorts an indexed array in ascending order |
uasort() | Sorts an array by values using a user-defined comparison function |
uksort() | Sorts an array by keys using a user-defined comparison function |
usort() | Sorts an array using a user-defined comparison function |