foreach traversal
Basic syntax:
foreach ( array name as key variable = = value variable )
{
Loop Body
}
foreach ( array name as value variable )
{
Loop Body
}
Array pointer-related functions
Key ( array name ): Gets the key of the current element of the array
Current ( array name ): Gets the value of the present element of the array
Next ( array name ): Moves the array pointer down one
Reset ( array name ): resets the pointer to the array (the pointer to the array is re-directed to the first element)
End ( array name ): is reset to the last element!
Prev ( array name ): moves the array pointer up
Each ( array name ):: the function of key,current,next function
$each [0],$each [' key '] represents the key of the current element of the original array,$each [1],$each [' value '] represents the value of the current element of the original array
List: is a system function, it can use an indexed array, one-time to assign values to multiple variables!
List ($v 1, $v 2, $v 3) = $arr: $v 1 corresponds to $arr 1[0], $v 2 corresponds to $arr 1[1], $v 3 corresponds to $arr 1[2]
Common array Functions:
COUNT ( array name ): calculates and returns the number of elements in an array or the number of attributes in an object
Range: calculates and returns the number of elements in an array or the number of attributes in an object
Range (A,B,C): A: start character or number ; B: end character or number ; C Pace ( can save, default is 1): Jump a few characters or numbers at a time
Array_merge (): merges the cells of one or more arrays, and the values in an array are appended to the previous array. Returns an array as the result.
Array_rand: The function is to randomly extract the keys of several elements within the array! and returns an indexed array!
PHP Syntax Basics 6