Explore the PHP Array functions list with descriptions, featuring a range of built-in functions designed for handling PHP arrays. These functions are an integral part of the PHP core, requiring no additional installation for utilization.
Several frequently employed array functions in PHP include count(), array_push(), array_pop(), array_slice(), array_merge(), array_reverse(), and others. These functions enable you to access and manipulate arrays efficiently. In the PHP language, both simple and multi-dimensional arrays are supported.
PHP Array Functions List with Description
SR. No. | Function | Description |
---|---|---|
1 | array_change_key_case() | Changes all keys in an array to lowercase or uppercase |
2 | array_chunk() | Splits an array into chunks of arrays |
3 | array_column() | Returns the values from a single column in the input array |
4 | array_combine() | Creates an array by using the elements from one “keys” array and one “values” array |
5 | array_count_values() | Counts all the values of an array |
6 | array_diff_assoc() | Compare arrays, and returns the differences (compare keys and values) |
7 | array_diff_key() | Compare arrays, and returns the differences (compare keys only) |
8 | array_diff_uassoc() | Compare arrays, and returns the differences (compare keys and values, using a user-defined key comparison function) |
9 | array_diff_ukey() | Compare arrays, and returns the differences (compare keys only, using a user-defined key comparison function) |
10 | array_diff() | Compare arrays, and returns the differences (compare values only) |
11 | array_fill_keys() | Fills an array with values, specifying keys |
12 | array_fill() | Fills an array with values |
13 | array_filter() | Filters the values of an array using a callback function |
14 | array_flip() | Flips/Exchanges all keys with their associated values in an array |
15 | array_intersect_assoc() | Compare arrays and returns the matches (compare keys and values) |
16 | array_intersect_key() | Compare arrays, and returns the matches (compare keys only) |
17 | array_intersect_uassoc() | Compare arrays, and returns the matches (compare keys and values, using a user-defined key comparison function) |
18 | array_intersect_ukey() | Compare arrays, and returns the matches (compare keys only, using a user-defined key comparison function) |
19 | array_intersect() | Compare arrays, and returns the matches (compare values only) |
20 | array_key_exists() | Checks if the specified key exists in the array |
21 | array_keys() | Returns all the keys of an array |
22 | array_map() | Sends each value of an array to a user-made function, which returns new values |
23 | array_merge_recursive() | Merges one or more arrays into one array recursively |
24 | array_merge() | Merges one or more arrays into one array |
25 | array_multisort() | Sorts multiple or multi-dimensional arrays |
26 | array_pad() | Inserts a specified number of items, with a specified value, to an array |
27 | array_pop() | Deletes the last element of an array |
28 | array_product() | Calculates the product of the values in an array |
29 | array_push() | Inserts one or more elements to the end of an array |
30 | array_rand() | Returns one or more random keys from an array |
31 | array_reduce() | Returns an array as a string, using a user-defined function |
32 | array_replace_recursive() | Replaces the values of the first array with the values from following arrays recursively |
33 | array_replace() | Replaces the values of the first array with the values from following arrays |
34 | array_reverse() | Returns an array in the reverse order |
35 | array_search() | Searches an array for a given value and returns the key |
36 | array_shift() | Removes the first element from an array, and returns the value of the removed element |
37 | array_slice() | Returns selected parts of an array |
38 | array_splice() | Removes and replaces specified elements of an array |
39 | array_sum() | Returns the sum of the values in an array |
40 | 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) |
41 | array_udiff_uassoc() | Compare arrays, and returns the differences (compare keys and values, using two user-defined key comparison functions) |
42 | array_udiff() | Compare arrays, and returns the differences (compare values only, using a user-defined key comparison function) |
43 | 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) |
44 | array_uintersect_uassoc() | Compare arrays, and returns the matches (compare keys and values, using two user-defined key comparison functions) |
45 | array_uintersect() | Compare arrays, and returns the matches (compare values only, using a user-defined key comparison function) |
46 | array_unique() | Removes duplicate values from an array |
47 | array_unshift() | Adds one or more elements to the beginning of an array |
48 | array_values() | Returns all the values of an array |
49 | array_walk_recursive() | Applies a user function recursively to every member of an array |
50 | array_walk() | Applies a user function to every member of an array |
51 | array() | Creates an array |
52 | arsort() | Sorts an associative array in descending order, according to the value |
53 | asort() | Sorts an associative array in ascending order, according to the value |
54 | compact() | Create array containing variables and their values |
55 | count() | Returns the number of elements in an array |
56 | current() | Returns the current element in an array |
57 | each() | Deprecated from PHP 7.2. Returns the current key and value pair from an array |
58 | end() | Sets the internal pointer of an array to its last element |
59 | extract() | Imports variables into the current symbol table from an array |
60 | in_array() | Checks if a specified value exists in an array |
61 | key() | Fetches a key from an array |
62 | krsort() | Sorts an associative array in descending order, according to the key |
63 | ksort() | Sorts an associative array in ascending order, according to the key |
64 | list() | Assigns variables as if they were an array |
65 | natcasesort() | Sorts an array using a case insensitive “natural order” algorithm |
66 | natsort() | Sorts an array using a “natural order” algorithm |
67 | next() | Advance the internal array pointer of an array |
68 | pos() | Alias of current() |
69 | prev() | Rewinds the internal array pointer |
70 | range() | Creates an array containing a range of elements |
71 | reset() | Sets the internal pointer of an array to its first element |
72 | rsort() | Sorts an indexed array in descending order |
73 | shuffle() | Shuffles an array |
74 | sizeof() | Alias of count() |
75 | sort() | Sorts an indexed array in ascending order |
76 | uasort() | Sorts an array by values using a user-defined comparison function and maintains the index association |
77 | uksort() | Sorts an array by keys using a user-defined comparison function |
78 | usort() | Sorts an array by values using a user-defined comparison function |
Further Details, Click here
Also Check
Keep up the incredible work! I can’t wait to see what you write next.