Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

PHP 5 Array function


May 11, 2021 PHP


Table of contents


PHP 5 Array function

This chapter begins with an introduction to common functions in PHP functions, and begins with array functions!


Introduction to PHP Array

The PHP Array function allows you to access and manipulate arrays.

Supports simple arrays and multi-dimensional arrays.


Installation

The PHP Array function is part of the PHP core. These functions can be used without installation.


PHP 5 Array function

function describe
array() Create an array.
array_change_key_case() Returns its key to an array of uppercase or lowercase.
array_chunk() Segment an array into new array blocks.
array_column() Returns the value of a single column in an array.
array_combine() Create a new array by combining two arrays (one for the keyname array, one for key value arrays).
array_count_values() The number of times the value in the statistics array occurs.
array_diff() A comparison array, returns the difference set (only the key value only) of the two arrays.
array_diff_assoc() A comparison array, returns the difference set (comparison key name and key value) of the two arrays.
array_diff_key() The comparison array, returns the difference set of two arrays (only the key name).
array_diff_uassoc() The comparison array, returns the difference set of the two arrays (comparison key names and key values, using user-defined key name comparison functions).
array_diff_ukey() The comparison array, returns the difference set of two arrays (only the key name, using the user-defined key name comparison function).
array_fill() Fill an array with a given key value.
array_fill_keys() Fill an array with a given specified key name.
array_filter() Use the callback function to filter the elements in the array.
array_flip() Reverse / exchange the key name in the array and the corresponding associated key value.
array_intersect() The comparison array returns the intersection of two arrays (only the key value).
array_intersect_assoc() A comparison array, returns the intersection of two arrays (comparison key names and key values).
array_intersect_key() The comparison array, returns the intersection of two arrays (only the key name).
array_intersect_uassoc() The comparison array, returns the intersection of two arrays (compare key names and key values, using user-defined key name comparison functions).
array_intersect_ukey() The comparison array, returns the intersection of two arrays (only the key name, using the user-defined key name comparison function).
array_key_exists() Check if the specified key name exists in an array.
array_keys() Returns all the key names in the array.
array_map() Return the new value on each value of the user-defined function to each value of a given array.
array_merge() Combine one or more numbers and an array.
array_merge_recursive() The recursively combines one or more numbers and is an array.
array_multisort() Sort multiple arrays or multi-dimensional arrays.
array_pad() Insert the specified number of elements with the specified value into the array.
array_pop() Delete the last element in the array (out of the stack).
array_product() Calculate the product of all values in the array.
array_push() Insert one or more elements into the end of the array (in the stack).
array_rand() Random from the array to select one or more elements, return the key name.
array_reduce() The array is simplified into a string by using the user-defined function, it is an iterative, and the array is simplified into a string and returns.
array_replace() Use the value of the back array to replace the value of the first array.
array_replace_recursive() Recreasing the value of the first array using the value of the back array.
array_reverse() The order in the original number group is flipped, create a new array and return.
array_search() Search for a given value in an array, if success, return the corresponding key name.
array_shift() Delete the first element in the array and returns the value of the deleted element.
array_slice() Returns the selected section in the array.
array_splice() Remove the specified elements in the array and replace them with other values.
array_sum() Returns the sum of all values in the array.
array_udiff() A comparison array, returns two arrays (only key values, using a user-defined key name comparison function).
array_udiff_assoc() The comparison array, returns the difference set of the two arrays (comparison key name and key value, using the built-in function comparison key name, using the user-custom function to compare the key value).
array_udiff_uassoc() A comparison array, return two arrays (comparison key names, key values, using two user-defined key name comparison functions).
array_uintersect() A comparison array, returns the intersection of two arrays (only the key value, using a user-defined key name comparison function).
array_uintersect_assoc() A comparison array, returns the intersection of two arrays (comparison key names and key values, using the built-in function comparison key name, using the user-defined function comparison key value).
array_uintersect_uassoc() A comparison array, returns the intersection of two arrays (comparison key names and key values, using two user-defined key name comparison functions).
array_unique() Delete the value repeated in the array.
array_unshift() Insert one or more elements at the beginning of the array.
array_values() Returns all values in the array.
array_walk() Apply user functions for each member of the array.
array_walk_recursive() Apply user functions to each member in the array.
arsort() Decord order of the key values in accordance with the key value.
asort() Sort by ordered the associated array according to the key value.
compact() Create an array that contains the variable name and its value.
count() Returns the number of elements in the array.
current() Returns the current element in the array.
each() Returns the current key / value pair in the array.
end() The internal pointer of the array points to the last element.
extract() Import variables into the current symbol table from an array.
in_array() Check if there is a specified value in the array.
key() Get the key name from the associated array.
krsort() Sort the associated array in descending order in the key name.
ksort() Sort the associated array according to the key name ascending order.
list() Assign a value in the array to some array variables.
natcasesort() Use the "Natural Sort" algorithm to the array to do not distinguish between uppercase and lowercase letters.
natsort() Sort the array with the "Natural Sort" algorithm.
next() Move the internal pointer in the array forward.
pos() Current () alias.
prev() Return the internal pointer of the array to one.
range() Create an array of elements that contain specified ranges.
reset() Point the internal pointer of the array to the first element.
rsort() Descending order sorting for numeric arguments.
shuffle() Replace the elements in the array according to the random order.
sizeof() Alias of count ().
sort() Decorption sequencing the numerical array.
uasort() Use the user-defined comparison function to sort the key values in the array.
uksort() Use the user-defined comparison function to sort the key names in the array.
usort() Use the user-defined comparison function to sort the array.
That's all there is to the Array function in PHP, read it carefully!