PHP array functions

Source: Internet
Author: User
List (): traverses the array array_map (function_name, array): The first parameter is the function used to modify the elements of the delayed array. The second function is the settype (var, type_string) of the array to be iterated ): converting the first parameter to the specified data type may increase the system overhead of unset (elem1 [, elem2...

List (): traverses the array

Array_map (function_name, array): The first parameter is the function used to modify the elements of the delayed array. The second function is the array to be iterated.

Settype (var, type_string): converts the first parameter to a specified data type, which may increase system overhead.

Unset (elem1 [, elem2. ..]) deletes the specified array element. after deletion, PHP automatically adjusts the index, but does not compress the array.

Array_values (array): compresses an array into a dense array.

Array_splice (array, start_index, length): delete length elements from start_index in the array. After deletion, PHP will automatically recreate the index and compress the array.

Array_shift (array): deletes the first element of the array and automatically compresses the array to recreate the index.

Array_pop (array): deletes the last element of the array and automatically compresses the array to recreate the index.

Array_pad (array, num, padString)

Array_splice (array, num): deletes all elements except the previous num element. if num is negative, the last num is deleted.

Array_merge (array1, array2): append the elements in array 1 to array 2. [if it is a numeric index during merge, the index is rebuilt. if it is a string key, the value of the second array overwrites the original value]

Join (string, array): concatenates elements of the array with a string to form a string.

Array_push (array, value): add the element value to the end of the array.

Array_key_exists (key_string, array): Check whether the array has a key key_string.

In_array (value, array): Check whether the array contains value

Array_search (value, array): searches for the position of value in the array. if the value does not exist, false is returned. if there are multiple values, a random value is returned.

Max (array): obtains the largest element in the array.

Min (array): obtains the smallest element in the array.

Arsort (array): sorts array elements by value

Array_reverse (array): reverse array

Sort (array): arrange array elements

Sort (array, SORT_NUMERIC): sort by number of digits

Asort (array): retains the key-value relationship to sort the array elements

Natsort (array): sorts array elements by natural sorting algorithm

Array_multisort (array1 [, array2. ..]): sorts multiple arrays.

Shuffle (array): random sorting of array elements.

Array_unique (array): returns a new array containing only unique elements. it is mainly used to delete repeated elements.

Array_walk (array, string function Name): uses the key-value pairs in array as two parameters to call function functions. [the array must be a one-dimensional array]

Array_pai_recursive (array, string function Name): Same as above, but the array is a two-dimensional array

PS: make it easy to view and call by yourself!

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.