Home >Backend Development >PHP Tutorial >An introduction to the plot of 'Love Has God's Will' and an introduction to some functions of operating arrays in PHP.
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 TRUE if found, otherwise return FALSE
boolean array_eky_exists (mixed key,array array)
Search for a specific value in the array, return TRUE if found, otherwise return FALSE
boolean array_search(mixed needle,array haystack[,boolean strict])
Get a new array composed of all 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 size of the array
integer count(array array[,int mode])
integer sizeof(array array[,int mode])
Statistics the frequency 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 Then the order of the array key values remains unchanged
array array_reverse(array array[,boolean preserve_key])
Replace the 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 value , useful for sorting integers or floating point numbers
SORT_REGULAR, sort according to ASCII values
SORT_STRING, sort in the correct order that is close to human recognition
asort function key value order remains unchanged
void sort(array array[,int sort_flags])
void asort(array array[,int sort_flags])
Sort array in reverse order, sort_flags parameter is optional, default behavior
SORT_NUMBERIC, sort by numerical value, useful for sorting integers or floating point numbers
SORT_REGULAR, sort by ASCII value
SORT_STRING, by proximity The known correct order sorting
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 sorting of array
boolean ksort(array array[,int sort_flags])
Key value sorting of array in reverse order
boolean krsort(array array[,int sort_flags])
Sort according to user-defined order
void usort(array array,callback function_name)
Merge the arrays together and return 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
key sum The values form a new array
array array_combine(array key, array value)
Return a part of the array, starting from the key offset and ending at offset+length
array array_slice(array array, int offset [,int length])
Delete from offset All elements starting from offset+length and returning the deleted elements in the form of array
array array_splice(array, int offset [,int length[,array peplacement]])
Find the intersection of the arrays, the key value is the first Key values in the array
array array_intersect(array array1,array array2[,arrayN...])
The intersection of the arrays contains equal key values, and the key value is the key value in the first array
array array_intersect_assoc(array array1,array array2 [,arrayN……])
Find the difference set of arrays, the first array has a value that does not exist in other arrays
array array_diff(array array1,array array2[,arrayN……])
Find the difference set of arrays, the first one Arrays contain equal key values that are not found in other arrays
array array_diffassoc(array array1,array array2[,arrayN...])
Returns one or more key values in the array
mixed array_rand(array array[,int num_entries])
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])
The above has introduced some functions of PHP operation arrays, including the plot introduction of Love Has Its Own Divine Will. I hope it will be helpful to friends who are interested in PHP tutorials.