traversal of an array * * 1. Loop through the array using the FOR statement * A. Other languages (only this way) * B. This way in PHP is not our preferred method * C. The array must be an indexed array, and the subscript must also be contiguous * (Index array subscript Also Can be non-sequential, arrays also have associative arrays) * * * 2. Iterate through an array with a foreach statement * foreach (array variable as variable value) {*//loop body *} * A. The number of cycles is determined by the number of elements in the array * b. Each loop assigns the elements in the array to the following variable * * f Oreach (array variable as subscript variable = = value variable) {* *} * * 3. The while () list () all () combination loops through the array * * each () function, * A. An array is required as a parameter * B. The returned array is also an array of * C. Returned arrays are 0, 1, ke Y, value four subscript (fixed) * 0 and key subscript are the keys of the current parameter array element * 1 and value subscript is the value of the current logarithmic array element * d. The default is that the current element is the first element * E. The current element is moved backwards after each execution * f. If the function is executed again to the last element, False * *//array ([1] = 1 [value] = 1 [0] + = ID [key] = + ID) * * list () function * A. List () =array (); You need to assign an array to the function * B. The number of elements in the array is the same as the number of parameters in the list () function * C. Each element value in the array is assigned a value of each parameter in the list () function, and list () converts each parameter to the variable * d. list () can only receive indexed array * E The index's subscript order *//* $user =array ("id" =>1, "name" = "Zhangsan", "Age" =>10, "Sex" and "Nan"), while ($arr =each ($user)) {//echo $Arr[0]. " ==> ". $arr [1]." <br> "; Echo $arr [" Key "]." ----> ". $arr [" Value "]." <br> ";} Use the inner pointer of the array to control the function next (array);p rev (array), reset (array) end (array), current (array), key (array); */
Explode () function string split into array function
PHP Learning Notes--multiple traversal methods commonly used in arrays