Advertisement

PHP Array Functions

PHP Array Introduction

Array functions allow you to access and manipulate arrays.

It supports single and multi-dimensional arrays.

installation

PHP array functions belong to the core. No installation needed to use these functions.

PHP 5 Array Functions

function description
array () Create an array.
array_change_key_case () The array is changed all keys to lowercase or uppercase.
array_chunk () The array is divided into a new array blocks.
array_column () Returns the value of an input array in a single column.
array_combine () To create a new array by combining two arrays.
array_count_values () Number of statistical values ​​in an array appearing for.
array_diff () Comparison list, returns the difference set (just compare keys).
array_diff_assoc () Comparison list, returns the difference set (compare key names and values).
array_diff_key () Comparison list, returns the difference set (just compare keys).
array_diff_uassoc () Comparison list, returns the difference set (compare key names and values, use a user-defined function keys for comparison).
array_diff_ukey () Comparison list, returns the difference set (just compare keys using a user-defined function keys for comparison).
array_fill () With the given key fill an array.
array_fill_keys () It fills an array with the specified key name given key.
array_filter () Filter elements in an array using a callback function.
array_flip () Switching array keys and values.
array_intersect () Comparison list, returns the intersection (just compare keys).
array_intersect_assoc () Comparison list, returns the intersection (compare key names and values).
array_intersect_key () Comparison list, returns the intersection (just compare keys).
array_intersect_uassoc () Comparison list, returns the intersection (compare key names and values, use a user-defined function keys for comparison).
array_intersect_ukey () Comparison list, returns the intersection (just compare keys using a user-defined function keys for comparison).
array_key_exists () Check the specified key exists in the array.
array_keys () Returns an array of all the keys.
array_map () Sends each value in the array to a user-defined function that returns the new value.
array_merge () The one or more arrays into one array.
array_merge_recursive () Recursively merge one or more arrays.
array_multisort () A plurality of array or multidimensional array sort.
array_pad () Filled with the value of the array to the specified length.
array_pop () Finally, delete an element of the array (the stack).
array_product () Calculate the product of all the values ​​in the array.
array_push () One or more elements inserted end of an array (stack).
array_rand () Returns an array of one or more random keys.
array_reduce () By using a user-defined function to return a string array.
array_replace () Use the back of the array value substitution value of the first array.
array_replace_recursive () Recursively using replacement values ​​behind the array of the first array.
array_reverse () Returns an array in reverse order.
array_search () Search array given value and returns the key.
array_shift () Remove the first element of the array, and returns the value of the element is deleted.
array_slice () Returns array selected part.
array_splice () Remove and replace the specified array element.
array_sum () Returns array values.
array_udiff () Comparison list, returns the difference set (only the comparison value, using a user-defined function keys for comparison).
array_udiff_assoc () Comparison list, returns the difference set (compare keys and values, use the built-in function that compares keys using a user-defined comparison function keys).
array_udiff_uassoc () Comparison list, returns the difference set (compare keys and values, uses two user-defined comparison function keys).
array_uintersect () Comparison list, returns the intersection (compare value only, using keys for a user-defined comparison function).
array_uintersect_assoc () Comparison list, returns the intersection (compare keys and values, use the built-in function that compares keys using a user-defined comparison function keys).
array_uintersect_uassoc () Comparison list, returns the intersection (compare keys and values, use the key names of the two user-defined comparison function).
array_unique () Remove duplicate values ​​in the array.
array_unshift () In the beginning of the array insertion of one or more elements.
array_values () Returns an array of all values.
array_walk () Each member of the array Apply a user function.
array_walk_recursive () Each member of the array Apply a user function recursively.
arsort () Associative arrays in descending order according to the key value.
asort () Associative array according to key values ​​in ascending order.
compact () Create a array of variable names and their values.
count () Returns the number of elements in the array.
current () Returns the current element in the array.
each () Returns an array of the current key / value pairs.
end () Internal array pointer points to the last element.
extract () Import array variables into the current symbol table.
in_array () Check whether the specified value is present in the array.
key () Obtain keys from the associative array.
krsort () An array in reverse order according to the key name.
ksort () Sorting an array in accordance with the key name.
list () The values ​​in the array is assigned to variables.
natcasesort () With the "natural order" algorithm array case insensitive sort.
natsort () Using a "natural order" algorithm to sort the array.
next () The array of internal pointer moves one forward.
pos () current () alias.
prev () Internal array pointer Rewind.
range () Create an array containing a range of elements.
reset () Internal array pointer points to the first element.
rsort () An array in reverse order.
shuffle () Array disrupted.
sizeof () count () alias.
sort () Sorting an array.
uasort () Using a user-defined comparison function to sort an array of keys.
uksort () Using a user-defined comparison function on the array sort keys.
usort () Use user-defined comparison function to sort the array.