1. Overview and installation
These functions allow you to use and manipulate arrays in different ways. Arrays are an essential tool for storing, managing, and manipulating variables.
PHP supports simple arrays and multi-dimensional arrays. Arrays can be created by users themselves or by other functions. There are many special database handling functions that can return arrays from database queries as well as some functions that return arrays.
Please refer to the chapter about arrays to learn more about how arrays are implemented and used in PHP.
No installation is required to use these functions, they are part of the PHP core.
2. A complete list of array functions
array_change_key_case — Returns an array whose string keys are all lowercase or uppercase Array, use the value of one array as its key name, and the value of another array as its value
array_count_values — Count the number of occurrences of all values in the array
array_diff_assoc — Calculate the difference set of the array with index check
array_diff_key — Use Compare key names to calculate the difference set of arrays
array_diff_uassoc — Use the callback function provided by the user to do index checking to calculate the difference set of the array
array_diff_ukey — Use the callback function to compare the key names to calculate the difference set of the array
array_diff — Calculate the difference set of the array Difference
array_fill_keys — Fill an array with specified keys and values
array_fill — Fill an array with a given value
array_filter — Use a callback function to filter cells in an array
array_flip — Swap keys and values in an array
array_intersect_assoc — Calculate the intersection of arrays with index checking
array_intersect_key — Calculate the intersection of arrays using key name comparison
array_intersect_uassoc — Calculate the intersection of arrays with index checking, use callback function to compare indexes
array_intersect_ukey — Use callback function to compare key names to calculate Intersection of arrays
array_intersect — Calculate the intersection of arrays
array_key_exists — Check whether the given key or index exists in the array
array_keys — Return all keys in the array
array_map — Apply the callback function to the given On the cell of the array
array_merge_recursive — Recursively merge one or more arrays
array_merge — Merge one or more arrays
array_multisort — Sort multiple arrays or multidimensional arrays
array_pad — Fill the array with values to the specified Length
array_pop — Pop the last element of the array (pop)
array_product — Calculate the product of all values in the array
array_push — Push one or more elements to the end of the array (push)
array_rand — From Randomly take one or more elements from the array
array_reduce — use the callback function to iteratively reduce the array to a single value
array_replace_recursive — use the passed array to recursively replace the elements of the first array
array_replace — use the passed array to replace The element of the first array
array_reverse — Returns an array with the cells in reverse order
array_search — Searches for a given value in the array, and returns the corresponding key name if successful
array_shift — Moves the cells at the beginning of the array out of the array
array_slice — Take out a segment from the array
array_splice — Remove a part of the array and replace it with other values
array_sum — Calculate the sum of all values in the array
array_udiff_assoc — Calculate the difference of the array with index checking and compare with the callback function Data
array_udiff_uassoc — Calculate the difference of arrays with index check, use callback function to compare data and index
array_udiff — Use callback function to compare data to calculate the difference of array
array_uintersect_assoc — Calculate intersection of arrays with index check, use callback Function to compare data
array_uintersect_uassoc — Calculate the intersection of arrays with index check, use callback function to compare data and index
array_uintersect — Calculate intersection of arrays, use callback function to compare data
array_unique — Remove duplicate values in array
array_unshift — Insert one or more cells at the beginning of the array
array_values — Return all values in the array
array_walk_recursive — Recursively apply a user function to each member of the array
array_walk — Apply a user function to each member of the array
array — Create a new array
arsort — Sort the array in reverse order and maintain the index relationship
asort — Sort the array and maintain the index relationship
compact — Create an array, including variable names and their values
count — Count the number of cells or objects in the array The number of attributes in
current — Returns the current unit in the array
each — Returns the current key/value pair in the array and moves the array pointer forward one step
end — Points the internal pointer of the array to the last unit
extract — Import variables from the array into the current symbol table
in_array — Check whether a value exists in the array
key_exists — Alias array_key_exists
key — Get the key name from the associative array
krsort — Sort the array as Reverse sorting of key names
ksort — Sort the array by key name
list — Assign the values in the array to some variables
natcasesort — Use the "natural sorting" algorithm to sort the array in a case-insensitive manner
natsort — Sort the array using the “natural ordering” algorithm
next — Move the internal pointer in the array forward one bit
pos — Alias for current
prev — Move the internal pointer of the array back one position
range — Create An array containing a specified range of cells
reset — Point the internal pointer of the array to the first cell
rsort — Reverse sort the array
shuffle — Shuffle the array
sizeof — Alias of count
sort — Sort the array Sort
uasort — Use user-defined comparison function to sort the values in the array and maintain index association
uksort — Use user-defined comparison function to sort the keys in the array
usort — Use user-defined The comparison function sorts the values in an array