Home >>PHP Array Functions

PHP Array Functions

PHP Array Predefined Functions

The PHP Array Functions is basically an inbuilt function in the PHP language that is used in order to create an array.

Please note that the array functions are basically the part of the core PHP. In order to use these functions there is no need of installation.

Here are some of the PHP arrays functions that are present in the PHP language. These arrays functions are depicted below along with a short description for easy understanding:

Function Description
array() Creates 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() Creates an array by using the elements from one "keys" array and one "values" array
array_count_values() Counts all the values of an array
array_diff() Compare arrays, and returns the differences (compare values only)
array_diff_assoc() Compare arrays, and returns the differences (compare keys and values)
array_diff_key() Compare arrays, and returns the differences (compare keys only)
array_diff_uassoc() Compare arrays, and returns the differences (compare keys and values, using a user-defined key comparison function)
array_diff_ukey() Compare arrays, and returns the differences (compare keys only, using a user-defined key comparison function)
array_fill() Fills an array with values
array_fill_keys() Fills 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 (compare values only)
array_intersect_assoc() Compare arrays and returns the matches (compare keys and values)
array_intersect_key() Compare arrays, and returns the matches (compare keys only)
array_intersect_uassoc() Compare arrays, and returns the matches (compare keys and values, using a user-defined key comparison function)
array_intersect_ukey() Compare arrays, and returns the matches (compare keys only, using a user-defined key comparison function)
array_key_exists() Checks if the specified key exists in the array
array_keys() Returns all the keys of an array
array_map() Sends each value of an array to a user-made function, which 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() Deletes 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, using a user-defined 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 in the reverse order
array_search() Searches an array for a given value and returns the key
array_shift() Removes the first element from an array, and returns the value of the removed element
array_slice() Returns selected parts of an array
array_splice() Removes and replaces specified elements of an array
array_sum() Returns the sum of the values in an array
array_udiff() Compare arrays, and returns the differences (compare values only, using a user-defined key comparison function)
array_udiff_assoc() Compare arrays, and returns the differences (compare keys and values, using a built-in function to compare the keys and a user-defined function to compare the values)
array_udiff_uassoc() Compare arrays, and returns the differences (compare keys and values, using two user-defined key comparison functions)
array_uintersect() Compare arrays, and returns the matches (compare values only, using a user-defined key comparison function)
array_uintersect_assoc() Compare arrays, and returns the matches (compare keys and values, using a built-in function to compare the keys and a user-defined function to compare the values)
array_uintersect_uassoc() Compare arrays, and returns the matches (compare keys and values, using two user-defined key comparison functions)
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 function to every member of an array
array_walk_recursive() Applies a user function recursively 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() Deprecated from PHP 7.2. 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

PHP Array Functions Index

Sr.No. Topics
1 PHP array() Function
2 PHP array_change_key_case() Function
3 PHP array_chunk() Function
4 PHP array_column() Function
5 PHP array_combine() Function
6 PHP array_count_values() Function
7 PHP array_diff() Function
8 PHP array_diff_assoc() Function
9 PHP array_diff_key() Function
10 PHP array_diff_uassoc() Function
11 PHP array_diff_ukey() Function
12 PHP array_fill() Function
13 PHP array_fill_keys() Function
14 PHP array_filter() Function
15 PHP array_flip() Function
16 PHP array_intersect() Function
17 PHP array_intersect_assoc() Function
18 PHP array_intersect_key() Function
19 PHP array_intersect_uassoc() Function
20 PHP extract() Function
21 PHP array_intersect_ukey() Function
22 PHP array_key_exists() Function
23 PHP array_keys() Function
24 PHP array_map() Function
25 PHP array_merge() Function
26 PHP array_merge_recursive() Function
27 PHP array_multisort() Function
28 PHP array_pad() Function
29 PHP array_pop() Function
30 PHP array_product () Function
31 PHP array_push() Function
32 PHP array_rand() Function
33 PHP array_reduce() Function
34 PHP array_replace() Function
35 PHP array_replace_recursive() Function
36 PHP array_reverse() Function
37 PHP array_search() Function
38 PHP array_shift() Function
39 PHP array_slice() Function
40 PHP array_splice() Function
41 PHP array_sum() Function
42 PHP array_udiff() Function
43 PHP array_udiff_assoc() Function
44 PHP array_udiff_uassoc( ) Function
45 PHP array_uintersect() Function
46 PHP array_uintersect_assoc() Function
47 PHP array_uintersect_uassoc() Function
48 PHP array_unique() Function
49 PHP array_unshift() Function
50 PHP array_values() Function
51 PHP array_walk() Function
52 PHP array_walk_recursive() Function
53 PHP arsort() Function
54 PHP asort() Function
55 PHP compact() Function
56 PHP count() Function
57 PHP current() Function
58 PHP each() Function
59 PHP end() Function
60 PHP in_array() Function
61 PHP key() Function
62 PHP krsort() Function
63 PHP ksort() Function
64 PHP list() Function
65 PHP natcasesort() Function
66 PHP natsort() Function
67 PHP next() Function
68 PHP pos() Function
69 PHP prev() Function
70 PHP range() Function
71 PHP reset() Function
72 PHP rsort() Function
73 PHP shuffle() Function
74 PHP sizeof() Function
75 PHP sort() Function
76 PHP uasort() Function
77 PHP uksort() Function
78 PHP usort() Function