PHP commonly used basic array functions

**
array_column — Return a specified column in the array

array_pop — Pop the last element of the array (pop the stack)

array_push — Push one or more elements to the end of the array (push the stack)

array_shift — Move the element at the beginning of the array out of the array

array_unshift — Insert one or more elements at the beginning of the array

array_chunk — Split an array into multiple arrays. Three parameters: the array to be split | how many values ​​are split in each array | [true/false]

array_merge — Merging one or more arrays. The numeric keys will be renumbered. The content is completely preserved. You can use the + operator to add arrays

array_diff — Calculate the difference of the array and return the value in array1 but not in array2 and any other parameter array. Returns an array that includes all the values ​​in array1 but not in any other parameter arrays. Note that the key name remains unchanged.

array_intersect (interactive) — Calculate the intersection of the arrays and return an array that contains all the values ​​in array1 that also appear in all other parameter arrays. Note that the key name remains unchanged.

array_unique — Remove duplicate values ​​in the array

array_rand — Randomly extract one or more elements from the array

array_product — Calculate the product of all values ​​in an array

array_sum — Calculate the sum of all values ​​in an array

array_count_values ​​— Count the number of occurrences of all values ​​in the array

array_combine — Create an array with the value of one array as its key and the value of another array as its value

array_search — Search for the given value in the array and return the corresponding key if successful

array_slice — Take a slice from the array

array_values ​​— Returns all the values ​​in the array

array_keys — Return some or all of the keys in the array

array_key_exists — Check if the given key or index exists in the array

is_array — Check whether a variable is an array

in_array — Check whether a value exists in the array

array_fill — Fill an array with a given value

array_fill_keys — Fill an array with specified keys and values

array_replace — Replace the elements of the first array with the passed array

sort()-sort the array in ascending order rsort()-sort the array in descending order

asort()-Sort the associative array in ascending order according to the value

ksort()-Sort the associative array in ascending order according to the key

arsort()-Sort associative arrays in descending order based on value

krsort()-Sort the associative array in descending order according to the key

usort — Use a user-defined comparison function to sort the values ​​in an array

uasort — Use a user-defined comparison function to sort the values ​​in an array and maintain index association

uksort — Use a user-defined comparison function to sort the keys in the array

shuffle — shuffle the array str_shuffle — shuffle a string randomly

explode — Use one string to split another string and return an array

implode — Convert the value of a one-dimensional array to a string

str_split — Convert a string to an array by length

split — Use regular expressions to split a string into an array
**

Guess you like

Origin blog.csdn.net/weixin_44900765/article/details/106258694
Recommended