This article mainly introduces the use of current, next and reset functions in PHP, and describes in detail the specific usage of the current, next, and reset functions for array operations in PHP in the form of an instance. For an in-depth understanding of the use of arrays has some reference value, the need for friends can refer to the following
$array =array (' Step One ', ' Step ', ' step three ', ' step Four '); Defines an array of echo current ($array). "
n "; Returns the first element of the array next ($array); The array pointer moves back one next ($array); The array pointer moves back one echo current ($array).
n "; Returns the current element of the array, the third value of Reset ($array); The pointer points to the first value of the array, echo current ($array).
n "; Returns the first value of the array// $info =array (' Red ', ' blue ', ' green '); Defines the array while ($result =current ($info)) { echo $result; echo "
"; Next ($info); } // $array =array (' fruit1 ' + ' apple ', ' fruit2 ' + ' orange ', ' fruit3 ' = ' grape ', ' fruit4 ' = ' Apple ', ' fruit5 ' = ' apple '); Define array while ($fruit _name=current ($array)) // loop Get array current value { if ($fruit _name== ' apple ')/ / If the current value is Apple { echo key ($array). '
'; Output the key name of the current value } next ($array); Move the array pointer down one step}
The end () function points the array's internal pointer to the last element and returns the value of the element, if successful.
The above describes the current, next and reset function usages in PHP, including the contents of the content, I hope that the PHP tutorial interested in a friend helpful.