reset() function in PHP || PHP Reset Function
×


reset() function in php

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.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments