Table of Contents
PHP has a set of built-in functions that you can use on arrays.
Function | Description |
---|---|
array() |
Create an array |
array_change_key_case() |
Changes all keys in an array to lowercase or uppercase |
array_chunk() |
Splits an array into chunks of arrays |
array_column() |
Returns the values from a single column in the input array |
array_combine() |
Combines two arrays into one array |
array_count_values() |
Counts all the values of an array |
array_diff() |
Compare arrays, and returns the differences (values) |
array_diff_assoc() |
Compare arrays, and returns the differences (values and keys) |
array_diff_key() |
Compare arrays, and returns the differences (keys) |
array_diff_uassoc() |
Compare arrays, and returns the differences (values and keys), using a user-defined key comparison function |
array_diff_ukey() |
Compare arrays, and returns the differences (keys), using a user-defined key comparison function |
array_fill() |
Fill an array with values |
array_fill_keys() |
Fill an array with values, specifying keys |
array_filter() |
Filters the values of an array using a callback function |
array_flip() |
Flips/Exchanges all keys with their associated values in an array |
array_intersect() |
Compare arrays, and returns the matches (values) |
array_intersect_assoc() |
Compare arrays, and returns the matches (values and keys) |
array_intersect_key() |
Compare arrays, and returns the matches (keys) |
array_intersect_uassoc() |
Compare arrays, and returns the matches (values and keys), using a user-defined key comparison function |
array_intersect_ukey() |
Compare arrays, and returns the matches (keys), using a user-defined key comparison function |
array_key_exists() |
Checks an array for a specified key, and returns true if the key exists and false if the key does not exist |
array_keys() |
Return all the keys of an array |
array_map() |
Applies a user-defined function to each element of an array |
array_merge() |
Merge one or more arrays into one array |
array_merge_recursive() |
Merge one or more arrays into one array recursively |
array_multisort() |
Sort multiple or multi-dimensional arrays |
array_pad() |
Insert a specified number of items, with a specified value, to an array |
array_pop() |
Deletes the last element of an array |
array_product() |
Calculate the product of values in an array |
array_push() |
Insert one or more elements to the end of an array |
array_rand() |
Pick one or more random keys out of an array |
array_reduce() |
Reduces an array to a single value by using a callback function |
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() |
Return an array in the reverse order |
array_search() |
Search an array for a value and return the key |
array_shift() |
Removes the first element from an array, and returns the value of the removed element |
array_slice() |
Extract a slice of the array |
array_splice() |
Remove a portion of the array and replace it with something else |
array_sum() |
Calculate the sum of values in an array |
array_udiff() |
Compare arrays, compare the values of the arrays, and returns the differences |
array_udiff_assoc() |
Compare arrays, compare the values of the arrays, and returns the differences (values and keys) |
array_udiff_uassoc() |
Compare arrays, compare the values of the arrays, and returns the differences (values and keys), using a user-defined key comparison function |
array_uintersect() |
Compare arrays, compare the values of the arrays, and returns the matches |
array_uintersect_assoc() |
Compare arrays, compare the values of the arrays, and returns the matches (values and keys) |
array_uintersect_uassoc() |
Compare arrays, compare the values of the arrays, and returns the matches (values and keys), using a user-defined key comparison function |
array_unique() |
Removes duplicate values from an array |
array_unshift() |
Add one or more elements to the beginning of an array |
array_values() |
Return all the values of an array |
array_walk() |
Apply a user-defined function to every element of an array |
array_walk_recursive() |
Apply a user-defined function recursively to every element of an array |
arsort() |
Sort an associative array in descending order, according to the value |
asort() |
Sort an associative array in ascending order, according to the value |
compact() |
Create an array from variables and their values |
count() |
Count all elements in an array, or something in an object |
current() |
Return the current element in an array |
each() |
Return the current key and value pair from an array and advance the array cursor |
end() |
Set the internal pointer of an array to its last element |
extract() |
Import variables into the current symbol table from an array |
in_array() |
Checks if a value exists in an array |
Document in project
You can Download PDF file.