you can use = to copy an array into another array.
Range (): Used to generate an arithmetic progression array.
$arr [0]= "Hello";//create an array of length 1, equivalent to $arr = Array ("0" = "Hello"); $arr [1]= "World"; $arr 2 = array ("Hello", "World");//equivalent to the above two lines of code foreach ( $arr as $now )//foreach Loop { echo $now. " "; } foreach ( $arr as $key + $value ) { echo $key. ":" $value. " "; } reset ($arr);//reset pointer //each function while ($ Element=each ($arr)) { echo $element [' key ']. ': ' $element [' value ']. " 1 "; } //Use list for loop reset ($arr); while (list ($key, $v) =each ($arr)) { echo $key. ":" $v. " "; } |
$arr 1+ $arr 2: Add the latter element to the back of the former, and key will not be added or overwritten.
Array sorting:
Sort (), Rsort (): Ascending, descending
Asort (), Arsort (): Sorting values
Ksort (), Krsort (): Key sort
Usort (), Uasort (), Uksort (): Custom comparison rules, custom comparison functions required
Other operations of the array:
Current (): Returns the element that is currently pointer, alias POS ()
Reset (), End (): pointer pointing to First, tail
Next (), prev (): Remove one/previous element
Shuffle (): random element that modifies the original array
Array_reverse (): Array in reverse order, the original array does not change
Array_work (): callback processing for each element in the array using a user-defined function
Count (), sizeof (): Calculates the array length
Array_count_values (): Statistical frequency of values
Extract (): Converts an array to a scalar form
The above describes the PHP and MySQL Web development notes-The 3rd chapter uses arrays, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.