PHP Array Functions

Online PHP guide provides PHP Array function tutorial for beginners. The in-built array functions allow you to interact and play with arrays in various ways. PHP holds single and multi-dimensional arrays. For database queries you will use specific array functions which returns database.

PHP Array Functions

Function Description PHP
array() creates an array with specified elements 3
array_change_key_case() changes all keys to lowercase or uppercase and then returns the result in array 4
array_chunk() specified array is divided into chunks of array  4
 array_combine()  takes 2 arrays as parameter and combines by using one array for keys and another for values  5
array_count_values() count the occurrences for each value and returns the result in array   4
array_diff()  compares specified array values, and returns the differences in array  4
array_diff_assoc() compares specified array keys and values, and returns the differences in array 4
array_diff_key() compares specified array keys, and returns the differences in array 5
array_diff_uassoc() compares specified array keys and values, using user-made function check, and returns the differences in array 5
array_diff_ukey() compares specified array keys, using user-made function check, and returns the differences in array 5
array_fill() returns an array with filling specified values 4
array_filter() returns a filtered element array, where element are filtered using a user-made function 4
array_flip() returns array with swapping all keys with their associated values 4
array_intersect() compares value from specified arrays, and returns the common array values in array 4
array_intersect_assoc() compares key- value pair from specified arrays, and returns the common key-value pair in array 4
array_ intersect_key() compares key from specified arrays, and returns the common keys in array 5
array_ intersect_uassoc() compares key- value pair from specified arrays using user-made function check, and returns the common key-value pair in array 5
array_intersect_ukey() compares key from specified arrays using user-made function check, and returns the common keys in array 4
array_key_exists() searches for the specified key in the specified array 4
array_keys() returns array with all the keys of an specified array 4
array_map() each array value is changed using user-made function, and array is returned with new values 4
array_merge() combines one or more arrays together to from one array 4
array_merge_recursive() combines one or more arrays together to from one array 4
array_multisort() takes multiple or multi-dimensional arrays as parameter and sorts 4
array_pad() returns an array by adding specified number of items, with a specified value, to an array 4
array_pop() returns an array by deleting the last element of an specified array 4
array_product() returns an array by calculating the product of the values in an specified array 5
array_push() returns an array by adding one or more elements to the end of an specified array 4
array_rand() returns one or more random keys from an array 4
array_reduce() converts an array to a string, using a user-made function and returns a result 4
array_reverse() returns an specified array in the reverse manner 4
array_search() searches for a given value in a specified array and returns the corresponding key 4
array_shift() deletes first element of specified array, and returns the value of the deleted element 4
array_slice() returns selected parts of an specified array 4
array_splice() returns modified array by, deleting and replacing specified elements of an array 4
array_sum() calculates the summation of the values in an array and returns it 4
array_udiff() compares array values using user-made function and returns an array 5
array_udiff_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 5
array_udiff_uassoc() Compares array keys and array values in user-made functions, and returns an array 5
array_uintersect() compares array keys and array values using user-made functions, and returns an array 5
array_uintersect_assoc() compares array keys, and compares array values using user-made function, and returns an array 5
array_uintersect_uassoc() compares array keys and array values using user-made functions, and returns an array 5
array_unique() returns an array by removing duplicate values from an array 4
array_unshift() returns an array by adding one or more elements at the start of an array 4
array_values() returns an array with all the values of an specified array 4
array_walk() sends every array keys and array values of specified array to user-made function 3
array_walk_recursive() applies a user-made function recursively to every array keys and array values 5
arsort() sorts an specified array in a decreasing manner and maintain index association 3
asort() sorts an specified array and maintain index association 3
compact() creates an array from variables and their values 4
count() counts number of elements in an specified array, or properties of an object 3
current() the current element from an specified array is returned 3
each() the current key-value pair, from an specified array is returned 3
end() the internal pointer of an array is set to point last element of an specified array 3
array_shift() deletes first element of specified array, and returns the value of the deleted element 4
extract() variables from an specified array are imported into the current symbol table 3
in_array() searches for a existence of a specified value in an array 4
key() returns a current key from an array to which the internal pointer of an array is pointing 3
krsort() returns an array by sorting an specified array by key in reverse manner 3
ksort() returns an sorted array by key 3
list() Assigns variables as if they were an array 3
natcasesort() returns an sorted array using a case insensitive i.e. “natural order” algorithm 4
natsort() returns an sorted array using a “natural order” algorithm 4 4
next() the internal array pointer of an specified array is incremented by one 3 3
pos() pos() alias to current() 3
prev() the internal array pointer of an specified array is decremented by one 3
range() creates an array with specified range of elements 3
reset() the internal pointer of an array is set to its first element 3
rsort() returns an sorted array in a reverse manner 3
shuffle() array is been shuffled 3
sizeof() alias to count() 3
sort() sort() array is been sorted 3
uasort() array is sorted using a user-made function and index association is maintained 3
uksort() array is sorted by keys using a user-made function 3
usort() array is sorted by values using a user-made function 4
SHARE
Previous articlePHP XML Functions
Next articlePHP String Introduction
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!