reset
Point the inner pointer of the array to the first unit
The reset()
function points the internal pointer to the first element in the array and outputs it.
Related methods:
Output the values of the current element and the next element in the array, and reset the internal pointer of the array to the first element in the array:
<?php $people = array ( "Bill" , "Steve" , "Mark" , "David" ) ; echo current ( $people ) . "<br>" ; echo next ( $people ) . "<br>" ; echo reset ( $people ) ; ?>
Try it yourself
Demonstrate all related methods:
<?php $people = array ( "Bill" , "Steve" , "Mark" , "David" ) ; echo current ( $people ) . "<br>" ; // The current element is Bill echo next ( $people ) . "<br>" ; // The next element of Bill is Steve echo current ( $people ) . "<br>" ; // The current element is Steve now echo prev ( $people ) . "<br>" ; // The previous element of Steve is Bill echo end ( $people ) . "<br>" ; // The last element is David echo prev ( $people ) . "<br>" ; // The element before David is Mark echo current ( $people ) . "<br>" ; // The current current element is Mark echo reset ( $people ) . "<br>" ; // Move the internal pointer to the first element of the array, i.e. Bill echo next ( $people ) . "<br>" ; // The next element of Bill is Steve print_r ( each ( $people ) ) ; // Returns the key name and key value of the current element (currently Steve) and moves the internal pointer forward ?>
Try it yourself
reset ( array )
parameter | describe |
---|---|
array | Required. Specifies the array to be used. |