An introduction to some functions of operating arrays in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 15:26:21
Original
756 people have browsed it

Search for a specific value in the array, return TRUE if found, otherwise return FALSE
boolean in_array(mixed needle,array haystack[,boolean strict])

Find a specified key in the array, return if found TRUE otherwise returns FALSE
boolean array_eky_exists(mixed key,array array)

Search for a specific value in the array, if found return TRUE otherwise return FALSE
boolean array_search(mixed needle,array haystack[, boolean strict])

Get a new array composed of all the keys of the array
array array_keys(array array[,mixed search_value])

Get a new array composed of all the values ​​of the array
array array_values(array array)

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

integer sizeof(array array[,int mode])

Statistics the frequency of occurrence of array elements
array array_count_values(array array)

Delete duplicate values ​​in the array and return an array composed of unique values
array array_unique(array array)

Reverse the order of array elements. If preserve_key is TRUE, the order of array key values ​​remains unchanged
array array_reverse(array array[,boolean preserve_key])

Replace array keys and values
array array_flip(array array)

Array order sorting, the sort_flags parameter is optional, the default behavior is
SORT_NUMBERIC, sort by numerical value, useful for sorting integers or floating point numbers

SORT_REGULAR, sort by ASCII value

SORT_STRING, sort in the correct order that is close to what people know

asort function key value order remains unchanged

void sort(array array[,int sort_flags])

void asort(array array[,int sort_flags])

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

SORT_REGULAR, sort by ASCII value

SORT_STRING, sort in the correct order that is close to what people know

arsort function key value order remains unchanged

void rsort(array array[ ,int sort_flags])

void arsort(array array[,int sort_flags])

Natural sorting of arrays
void natsort(array array)

Case-insensitive Natural sorting
void natcasesort(array array)

Key-value pair array sorting
boolean ksort(array array[,int sort_flags])

Key-value pair array reverse order Sort
boolean krsort(array array[,int sort_flags])

Sort according to user-defined order
void usort(array array,callback function_name)

Merge arrays together , returns a combined array. The back of array_merge covers the front, array_merge_recursive merges together
array array_merge(array array1[array array2...])//More than one

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

keys and values ​​form a new array
array array_combine(array key,array value)

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

Delete all elements starting from offset and ending at offset+length, and return the deleted elements in the form of an array
array array_splice (array, int offset [,int length[,array peplacement]])

Find 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 arrays contains equal key values, and the key values ​​are the key values ​​in the first array
array array_intersect_assoc(array array1,array array2[,arrayN...])

Find the difference of arrays, the first array has a value that is not found in other arrays
array array_diff(array array1,array array2[,arrayN...])

Find the difference of arrays , the first array contains key values ​​that are equal to values ​​that are not found in other arrays
array array_diffassoc(array array1,array array2[,arrayN...])

Return one or more key values ​​in the array
mixed array_rand(array array[,int num_entries])

Random shuffle function
void shuffle(array input_array)

Sum the values ​​in the array
mixed array_sum (array array);

Decompose the array into a multi-dimensional array, which contains size elements
array array_chunk(array array, int size [,boolean preserve_keys])

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323960.htmlTechArticleSearch for a specific value in the array, return TRUE if found otherwise return FALSE boolean in_array(mixed needle,array haystack[ ,boolean strict]) Find a specified key in the array if...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!