Introduction to some functions of PHP operations array _ PHP Tutorial

Source: Internet
Author: User
Some functions of the PHP operation array. Search for a specific value in the array. if TRUE is returned, FALSEbooleanin_array (mixedneedle, arrayhaystack [, booleanstrict]) is returned. find a specified key in the array, if a specific value is searched in the array, TRUE is returned if Yes; otherwise FALSE is returned.
Boolean in_array (mixed needle, array haystack [, boolean strict])

Find a specified key in the array. If yes, return TRUE. Otherwise, return FALSE.
Boolean array_eky_exists (mixed key, array)

Search for a specific value in the array. If yes, return TRUE. Otherwise, return FALSE.
Boolean array_search (mixed needle, array haystack [, boolean strict])

Obtains a new array composed of all the keys in the array.
Array array_keys (array [, mixed search_value])

Obtains a new array composed of all values of the array.
Array array_values (array)

Determine the array size
Integer count (array [, int mode])

Integer sizeof (array [, int mode])

Count the occurrence frequency of array elements
Array array_count_values (array)

Deletes repeated values in an array and returns an array consisting of unique values.
Array array_unique (array)

Returns the element order of the array. if the value of preserve_key is TRUE, the order of the key values of the array remains unchanged.
Array array_reverse (array [, boolean preserve_key])

Replace the array key and value
Array array_flip (array)

Sort arrays sequentially. the sort_flags parameter is optional. default behavior.
SORT_NUMBERIC, sorted by numerical value, useful for sorting integers or floating-point numbers

SORT_REGULAR, sorted by ASCII value

SORT_STRING, which is sorted by the correct order of the nearest person

The key-value sequence of the asort function remains unchanged.

Void sort (array [, int sort_flags])

Void asort (array [, int sort_flags])

Array sorting in reverse order. the sort_flags parameter is optional. default behavior.
SORT_NUMBERIC, sorted by numerical value, useful for sorting integers or floating-point numbers

SORT_REGULAR, sorted by ASCII value

SORT_STRING, which is sorted by the correct order of the nearest person

The order of the key values of the arsort function remains unchanged.

Void rsort (array [, int sort_flags])

Void arsort (array [, int sort_flags])

Natural sorting of arrays
Void natsort (array)

Case-insensitive natural sorting
Void natcasesort (array)

Sort the key-value pairs in an array
Boolean ksort (array [, int sort_flags])

Sort the key-value pairs in reverse order.
Boolean krsort (array [, int sort_flags])

Sort by user-defined order
Void usort (array, callback function_name)

Merges the arrays to return a Union array. Array_merge overwrites the front, and array_merge_recursive is merged.
Array array_merge (array array1 [array array2…]) // More than one

Array array_merge_recursive (array array1, array array2 [, array…]) // More than two

Key and value form a new array
Array array_combine (array key, array value)

Returns a part of the array, starting from the offset and ending at the offse + length position.
Array array_slice (array, int offset [, int length])

Delete all elements starting from offset to ending with offset + length, and return the deleted elements as arrays.
Array array_splice (array, int offset [, int length [, array peplacement])

Returns the intersection of arrays. The key value is the key value in the first array.
Array array_intersect (array array1, array array2 [, arrayN…])

The intersection of the array contains the same key value. The key value is the key value of the first array.
Array array_intersect_assoc (array array1, array array2 [, arrayN…])

Evaluate the difference set of the array. the first array does not have values in other arrays.
Array array_diff (array array1, array array2 [, arrayN…])

Evaluate the difference set of the array. the first array does not have the same key value in other arrays.
Array array_diffassoc (array array1, array array2 [, arrayN…])

Returns one or more key values in the array.
Mixed array_rand (array [, int num_entries])

Shuffling function
Void shuffle (array input_array)

Summation of values in the array
Mixed array_sum (array );

Splits an array into a multi-dimensional array that contains size elements.
Array array_chunk (array, int size [, boolean preserve_keys])

Using boolean in_array (mixed needle, array haystack [, boolean strict]) find a specified key in the array, if...

Related Article

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.