Miscellaneous in arrays of PHP array functions

Source: Internet
Author: User

Array_change_key_case ($arr, Case_lower | | Case_upper) returns an array whose key names are all uppercase or lowercase

Array_rand ($arr, num) randomly extracts one or more cells from an array

Shuffle (& $arr) scrambling the array

Array_chunk ($arr, $size, BOOL) splits the $arr, each array is $size elements, and BOOL remains the original index


Array_combine ($arr, $arr 2) Merge two arrays $arr key Name Key name $arr 2 key value

Array_count_values ($arr); Returns the value of an array $arr the number of times the key name appears in the array

Array_slice ($arr) take a paragraph out of the array


Array_fill ($start, $Num, $value) fills Num times from start with value

Array_pad ($arr, Pad_size, Pad_value) uses value to add $arr to the length of size, the size is the positive complement of the array, or vice versa.


Array_merge ($arr, $arr 2, [...]) Merge one or two array key names with the same overlay

Array_merge_recursive ($arr, $arr 2 [...]) recursively merge one or more arrays


Array_reverse ($arr) returns an array of cells in reverse order


Array_filter ($arr, ' callback '); Filter arrays with callback functions

Array_unique ($arr); Move duplicate values in an array

Array_splice ($arr) Remove part of the array and replace it with other values



Array_flip ($arr); Reverses the array, if a value appears multiple times last key name as his value

Array_key_exists ($key, $arr) whether the given key name and index exist in the array

In_array ($key, $arr) whether a value exists in the array

Array_keys ($arr) returns all the key names in the array

Array_search (' key ', $arr) searches the array for the given value successfully returns the key name

Array_values ($arr) returns all the key values in the array

Count ($arr) The number of attributes in an array of cells or objects in the middle age

Array_sum ($arr) The and of all values in the array

List ($arr) assigns the values in the array to some variables


Array_map (' function ', $arr) functions The callback function on the cell of the given array;

Array_walk ($arr, ' function ') apply user function to each member in the array

Array_walk ($arr, ' callback ') apply user function recursively for each member in an array



Array_reduce ($arr, ' callback ', ' initial ') the array is reduced to a single value using the user-defined function of the array

Array_pridect ($arr) The product of all values in an array

Compact (' AA ', $arr) adds variables to the array

Extract ($arr) array to import variables into the current symbol table



Array_pop ($arr) POPs the last cell of the array to the length and minus one (out of the stack)

Array_push ($arr, mixed) presses one or more cells into the end of the array (into the stack)

Array_shift (& $arr); Move the cells at the beginning of the array to the divisor group

Array_unshift ($arr, $mixed); Insert one or more cells from the beginning of an array


Miscellaneous in arrays of PHP array functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.