1. Ultimate Reference to All PHP Array Functions

Since PHP arrays are the containers in the PHP programming language, and they allow us to store multiple values inside a single array. They do not have any limit and one can store an infinite number of values inside an array. This tutorial serves as a guide and reference list of all the PHP array functions, and anyone can find and know more about the functions, which can be used to manipulate the arrays.

1.1. How to Use Array Functions?

These PHP array functions are built-in functions in the PHP programming language, and there is no need to install or configure them for use. Therefore, we can utilize these functions freely without the need for any prior configuration.

Tutorial Contents:

  1. What are PHP Array Functions?
  2. Reference List
  3. Reference Links

2. Search Reference For PHP Array Functions

The below reference table has all the PHP array functions with an ultimate and up-to-date list that we can utilize in developing various projects. Type the name of the function and instantly find the associated array function with a brief description.

2.1. Alphabetical Reference

PHP Array Functions
Function Description
array() In order to create an array in PHP, we utilize this array() function.
array_change_key_case() Whenever, we need to change the array keys of an array, to uppercase or lowercase, we use the array array_change_key_case() function.
array_chunk() The array_chunk() function in PHP is used to divide an array into chunks of arrays.
array_column() Sometimes, we need to retrieve the values from a single column only, in that case, we use the array_column() function in PHP to get the job done.
array_combine() This PHP array_combine() function creates a single array from an array of keys and an array of values.
array_count_values() In order to count the values of an array, we use the array_count_values() function in the PHP language.
array_diff() This PHP array_diff() function compares the values of the two different arrays and returns only the difference between them.
array_diff_assoc() The PHP array_diff_assoc() function compares the keys and values of two arrays and returns the difference.
array_diff_key() Unlike PHP array_diff() function, the array_diff_key() function compare only the keys of two arrays and return the difference.
array_diff_uassoc() The PHP array_diff_uassoc() function relates two arrays' keys, values, and a user-defined function to return the difference.
array_diff_ukey() This PHP array_diff_ukey() function compares the keys of two arrays, and returns the difference in keys using a user-defined function.
array_fill() The PHP array_fill() function is utilized to fill an array with values.
array_fill_keys() Similar to PHP array_fill() function, the array_fill_keys() populates an array with values specifying associated keys.
array_filter() This PHP array_filter() function is utilized to filter the values of an array with the help of a callback function.
array_flip() While working with an array, the PHP array_flip() function flips or swaps the keys with the values.
array_intersect() In order to find common or alike values in an array, the PHP array_intersect() function returns the intersection of two arrays.
array_intersect_assoc() The PHP array_intersect_assoc() function compares two arrays i.e their keys and values and returns the matches.
array_intersect_key() This PHP array_intersect_key() function compares the keys of two arrays and returns the matches.
array_intersect_uassoc() In order to find the matches between two PHP arrays, we can also utilize a user-defined function with the array_intersect_uassoc() function, which compares the key and values.
array_intersect_ukey() This PHP array_intersect_ukey() function compares the keys of two arrays and returns a match with the help of a user-defined function.
array_is_list() The PHP array_is_list() function returns true if the given array is a list as an array is considered the list of its keys from 0 to onward.
array_key_exists() In order to check if a key exists or is available in an array, we can use this PHP array_key_exists() function.
array_key_first() This array_key_first() get the first key of an array without colliding the pointer position.
array_key_last() Just like the array_key_first(), this array_key_last() returns the last key of an array.
array_keys() The PHP array_keys() function returns all the keys of an array.
array_map() The PHP array_map() function utilizes a user-defined function and processes each value of an array with that function to get a new value.
array_merge() The array_merge() function merges the arrays into a single array.
array_merge_recursive() Unlike the array_merge(), the array_merge_recursively() function merges the arrays into a single array recursively.
array_multisort() The array_multi-sort function sorts multi-dimensional or multiple arrays in PHP.
array_pad() With the help of the array_pad() function, we can include a specified number of items along with a specified value.
array_pop() By using the array_pop() function, we can remove the last element of an array.
array_product() The array_product() function returns the product of the values of an array.
array_push() In order to add one or more elements at the end of an array, we can utilize the PHP array_push() function.
array_rand() By using the array_rand() function, we can get one or more random keys of an array.
array_reduce() With the help of the array_reduce() function, we can return an array as a string using a user-defined function.
array_replace() The array_replace() function replaces the values of the first array with the values of the following array.
array_replace_recursive() This PHP array_replace_recursive() function replaces the values of the first array with the values of the next array recursively.
array_reverse() The PHP array_reverse() function reverses the order of the array elements.
array_search() In order to find a value in an array, we can use the array_search() function, which returns the key of the matched value.
array_shift() The PHP array_shift() function is used to remove the first element of an array and returns the value of the removed item.
array_slice() This array_slice() function returns only the selected parts of an array.
array_splice() With the help of the PHP array_splice() function, we can remove and replace the specified items of an array.
array_sum() The PHP array_sum() function returns the sum of array values.
array_udiff() This array_udiff() function returns the differences between two arrays by comparing the values only and uses a user-defined function to compare the keys.
array_udiff_assoc() PHP array_udiff_assoc() function returns the differences by comparing the keys with a built-in function and the values with a user-defined function of two functions.
array_udiff_uassoc() PHP array_udiff_uassoc() function returns the difference by comparing the keys and values of two arrays with the help of two user-defined functions.
array_uintersect() The PHP array_uintersect() returns matches by comparing the values only and a user-defined function to compare the keys.
array_uintersect_assoc() The PHP array_uintersect_assoc() function utilizes a user-defined function to compare the values, and a built-in function to compare the keys and finally return the matches.
array_uintersect_uassoc() This PHP array_uintersect_uassoc() function utilizes two user-defined functions and returns the matches of two arrays comparing keys and values.
array_unique() This array_unique() function deletes the repeated items in an array and returns unique values array.
array_unshift() Among other PHP functions, the role of the array_unshift() is used to add one or more elements at the beginning of an array.
array_values() This array_values() function returns all the values of an array in PHP.
array_walk() The array_walk() is used to apply a user-defined function to each element of an array.
array_walk_recursive() A user-defined function is applied to each item of an array recursively using the PHP array_walk_recursive() function.
arsort() Unlike the asort(), the arsort() function sorts an associative array in descending order with respect to its values.
asort() The PHP asort() function arranges an associative array in ascending order with respect to its values.
compact() This PHP compact() function formulates an array from the variables and their values.
count() Just like the sizeof() function, the count() function returns the number of elements in an array.
current() The current element in an array is returned by this PHP current() function.
each() This PHP each() function returns the current item key and the value in an array.
end() The internal pointer of the array in PHP goes to the last element of the array using the end() function.
extract() The PHP extract() function converts the array keys into variables that can access the associated value.
in_array() In order to find if a value exists inside an array, we can utilize the PHP in_array() function.
key() The PHP key() function returns the internal current position key of an array.
key_exists() Just like PHP array_key_exists(), the key_exists() function returns true if a key is present in an array.
krsort() Unlike the ksort() function in PHP, the krsort() function sorts an associative array in descending order with respect to keys.
ksort() The PHP ksort() function arranges an associative array in ascending order with respect to keys.
list() This PHP list() function is utilized to assign the variables to the values of an array so that the array values can be acquired using those variables.
natcasesort() The PHP natcasesort() function sorts an array by a case-insensitive "natural order" algorithm.
natsort() A natural order algorithm is used to sort a PHP array using the natsort() function.
next() The internal pointer of an array moves or advances forward by using this PHP next() function.
pos() The value of the current element in an array is returned by the PHP pos() function.
prev() The PHP prev() function rewinds the internal pointer of an array.
range() This PHP range() function creates an array with a range of elements.
reset() The PHP reset() function sends the internal pointer of an array to its first item.
rsort() Unlike the sort() function, the PHP rsort() function sorts an indexed array in descending order.
shuffle() The PHP shuffle() function randomize the elements of an array.
sizeof() Just like the PHP count() function, the sizeof() function is used to find the number of elements in an array.
sort() This PHP sort() function sorts an indexed array in ascending order.
uasort() A user-defined function is used to sort an array based on the values using the PHP uasort() function.
uksort() The PHP uksort() function sorts an array with a user-defined function with the help of uksort() function by using keys.
usort() In order to sort a PHP array with a user-defined function, we can utilize the usort() function.

3. Reference Links

For this reference tutorial, we searched and filtered the below resources to write up a clear, up-to-date, and ultimate guide of all array functions in the PHP programming language.

  • We utilized W3schools.com as a reference to build up this ultimate reference of all PHP arrays functions.
  • We also consulted PHP.NET to compile an up-to-date and latest list of all PHP arrays functions in this reference.
Give Us Your Feedback
OR
If You Need Any Help!
Contact Us