There are many php functions that can be queried when needed.
Copy codeThe Code is as follows:
<? Php
/*
# No size limit on the array: $ arr [0] = 1; $ arr [1] = 2; $ arr = array ("0", "1 "); $ list ($ num1, $ num2) = $ arr;
Array range (int low, int high [, int step])
Low minimum, high maximum, step size
Int array_unshift (array, mixed vari) inserted before the array
Add at the end of the array_push Array
Array_shift array header Deletion
Remove the tail of the array_pop Array
# Locating Arrays
Boolean in_array (mixed needle, array haystack, [, boolean strict])
Boolean array_key_exists (mixed key, array) Search for key keys
Array_search () searches for associated array values
Array_keys () returns an array containing all the keys searched.
Array_values () returns all values of the array.
# Traversing Arrays
Mixed key (array)
Current (array) Get the current array value
Array each (array) returns the current key and Value Pair
Next (array) points to the next
Prev (array) Move to the previous one
Move reset (array) to the first
End (array) Move to the last
# Passing array values to Functions
Boolean array_walk (array & array, callback function, [, mixed userdata])
# Determine the size and uniqueness of the array
Integer count (array [, int mode]) similar to sizeof ()
Array array_count_values (array) Grouping statistics on the number of times each value appears
Array_unique () deletes duplicate values to ensure uniqueness
# Sorting
Array_reverse () Reverse Order
Array_flip () Swap key and Value
Void sort (array [, int sort_flags])
Sort_flgs {[SORT_NUMBERIC numerical sorting], [SORT_REGULAR sorting by ASCII], [SORT_STRING]}
Asort () Ascending
Rsort () Reverse Order
Arsort () Reverse Order
Natsort () Natural sorting
Natcasesort () is case-insensitive and naturally sorted
Sort ksort () key values
Sort krsort () in reverse order
Void usort (array, callback function name) User-Defined sorting
# Merge, split, combine, and split arrays
Array_merge_recursive () Merge
Array_merge_combine () append
Array_merge () connects to the new array
Array_slice (array, int offse [, int length]) Split
Array intersection of array_intersect () and array_intersect_assoc ()
Array_diff (), array_diff_assoc () difference set
Array_rand (), shuffle () random array
Array_sum () summation
Array_chunk is divided into multi-dimensional arrays.
*/
// Create an even array ranging from 0 to 20. Step 2 is used.
$ Even = range (0, 20, 2 );
// Print the Array
Print_r ($ even );
// Determine whether it is an array
Printf ("this number is an array: % s <br/>", (is_array ($ even )? "True": "false "));
Echo "<br> ";
// Add a subitem to the array header and print it
Array_unshift ($ even, 522,54 );
Print_r ($ even );
// Define a variable and search in the array. The variable is found when it exists.
$ Sa = 522;
If (in_array ($ sa, $ even )){
Echo "find it $ sa ";
};
Echo "<br/> ";
// Search for the key keys of the array
If (array_key_exists (4, $ even )){
Echo $ even [4]. "exists .";
}
Echo "<br/> ";
Print_r (array_values ($ even ));
// Print array Traversal
While ($ key = key ($ even )){
Echo "<br/>". $ key;
Next ($ even );
}
// Count the array size
Echo "<br/> ";
Echo count ($ even );
// Sort
Echo "<br> ";
Sort ($ even );
Print_r ($ even );
?>