reset() function in php
0 2061
PHP reset() function is used to reset the position of array pointer means it set the current pointer of an array to the starting item of the array.
Syntax:
reset($array);
here,
$array is a PHP array.
Example:
<?php $arr1 = array("apple","orange","banana","fig",); $last_value=end($arr1); // it will set the array pointer to last item and return the last item of array i.e. fig $reset_value=reset($arr1); // it will reset the array pointer and return the initial element of array i.e. apple echo "Reset item of array is $reset_value "; ?>
Output:
Note: You should also read prev(), next(), current() and end() functions.
Share:
Comments
Waiting for your comments