You can use = to copy an array into another array.
range(): used to generate an arithmetic sequence array.
$arr[0]=”hello”;//Directly create an array with a length of 1, which is equivalent to $arr = array(“0”=>”hello”); $arr[1]=”world”; $arr2 = array(“hello”,”world”);//Equivalent to the above two lines of code foreach($arr as $ now)//foreach loop { echo $now." } foreach($arr as $key=& gt;$ value) { echo $key.":".$value." } reset($arr);//Reset pointer //each function while($element=each($arr)) { echo $element['key'].":".$element[ 'value']."1 } //Use list to loop reset($arr); while(list($key . $arr1+$arr2: Add the latter element to the back of the former. The same key will not be added or overwritten.
Array sorting: sort(), rsort(): ascending order, descending order |
ksort(), krsort( ): Key sorting
usort(), uasort(), uksort(): Custom comparison rules, custom comparison functions are required
Other operations on arrays:
current(): Return the current pointer element, alias pos()
reset(), end(): pointer points to the beginning and end
next(), prev(): remove the next/previous element
shuffle() : Random elements, will modify the original array
use using a user’s own function ’ s ‐ ‐ ‐ ‐ ‐ ‐ being in reverse order,
) Count (), sizeof (): Calculate array lengthArray_Count_values (): Statistically frequency of value
Extract ()
The above has introduced the notes of "php and mysql web development" - Chapter 3 using arrays, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.