Loading... # PHP Array Functions The following section contains a list of PHP array functions along with a brief description. ## PHP Array Functions Here is a complete list of array functions belonging to the latest PHP 7. These functions are the part of the PHP core so you can use them within your script without any further installation. Also, deprecated function such as each() is not included in the list. array\_change\_key\_case() Changes the case of 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() Creates an array by using one array for keys and another for its values. --- array\_count\_values() Counts all the distinct values of an array. --- array\_diff() Compare arrays values, and returns the differences. --- array\_diff\_assoc() Compare arrays values, with additional key check, and returns the differences. --- array\_diff\_key() Compare arrays keys, and returns the differences. --- array\_diff\_uassoc() Compare arrays values, with additional key check using a user-defined key comparison function, and returns the differences. --- array\_diff\_ukey() Compare array keys, using a user-defined key comparison function, and returns the differences. --- array\_fill() Fills an array with values. --- array\_fill\_keys() Fills an array with values, specifying keys. --- array\_filter() Filters elements of an array using a user-defined function. --- array\_flip() Flips or exchanges all keys with their associated values in an array. --- array\_intersect() Compare arrays values, and returns the matches. --- array\_intersect\_assoc() Compare arrays values, with additional key check, and returns the matches. --- array\_intersect\_key() Compare arrays keys, and returns the matches. --- array\_intersect\_uassoc() Compare arrays values, with additional key check using a user-defined key comparison function, and returns the matches. --- array\_intersect\_ukey() Compare arrays keys, using a user-defined key comparison function, and returns the matches. --- array\_key\_exists() Checks if the specified key exists in the array. --- array\_key\_first() Gets the first key of an array. --- array\_key\_last() Gets the last key of an array. --- array\_keys() Returns all the keys or a subsets of the keys of an array. --- array\_map() Sends the elements of the given arrays to a user-defined function, which may use it to returns new values. --- array\_merge() Merges one or more arrays into one array. --- array\_merge\_recursive() Merges one or more arrays into one array recursively. --- array\_multisort() Sorts multiple or multi-dimensional arrays. --- array\_pad() Inserts a specified number of items, with a specified value, to an array. --- array\_pop() Removes the last element of an array, and returns the value of the removed element. --- 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() Reduce the array to a single value by using a user-defined 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() Returns an array with elements in reverse order. --- array\_search() Searches an array for a given value and returns the corresponding key if successful. --- array\_shift() Removes the first element from an array, and returns the value of the removed element. --- array\_slice() Extract a slice from an array. --- array\_splice() Removes a portion of the array and replace it with something else. --- array\_sum() Calculates the sum of values in an array. --- array\_udiff() Compares arrays values using a user-defined comparison callback function, and returns the differences. --- array\_udiff\_assoc() Compares arrays values using a user-defined comparison callback function, with additional key check, and returns the differences. --- array\_udiff\_uassoc() Compares the keys and values of arrays using two separate user-defined key and value comparison callback functions, and returns the differences. --- array\_uintersect() Compares arrays values using a user-defined comparison callback function, and returns the matches. --- array\_uintersect\_assoc() Compares arrays values using a user-defined comparison callback function, with additional key check, and returns the matches. --- array\_uintersect\_uassoc() Compares the keys and values of arrays using two separate user-defined key and value comparison callback functions, and returns the matches. --- array\_unique() Removes duplicate values 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-defined function to each element of an array. --- array\_walk\_recursive() Applies a user-defined function recursively to each element of an array. --- array() Creates an array. --- arsort() Sorts an associative array by value, in reverse or descending order. --- asort() Sorts an associative array by value, in ascending order. --- compact() Creates array containing variables and their values. --- count() Returns the number of elements in an array. --- current() Returns the current element in an array. --- end() Sets 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. --- key() Fetches a key from an array. --- krsort() Sorts an associative array by key, in reverse or descending order. --- ksort() Sorts an associative array by key, in ascending order. --- list() Assign 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() Returns the current element in an array. Alias of current() function. --- prev() Rewind 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 array in reverse or descending order. --- shuffle() Shuffles or randomizes the order of the elements in an array. --- sizeof() Returns the number of elements in an array. Alias of count() function. --- sort() Sorts an array in ascending order. --- uasort() Sorts an array using a user-defined comparison function and maintain index association. --- uksort() Sorts an array by keys using a user-defined comparison function. --- usort() Sorts an array by values using a user-defined comparison function. Last modification:September 15, 2024 © Allow specification reprint Like 如果觉得我的文章对你有用,请随意赞赏