Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can I reset an array in PHP?

Answer Posted / jude jeevanraj.p

Sometimes if you are moving through the various elements in
an array, you will want to return the pointer to the
beginning of the array.

This is easily done with the reset function, like this:
reset($array);

This returns the first element and sets it as the current
element.

Here is a little example just to make this technique clear:

<?php
$numbers = array("Item 1","Item 2","Item 3");
next($numbers);
$thisvalue = current($numbers); echo "We are now at
$thisvalue\n\n";
$first = reset($numbers);
echo "Back to $first";
?>

Is This Answer Correct ?    21 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain preg_Match and preg_replace?

967


What are escaping characters?

955


Which function gives us the number of affected entries by a query?

917


Is set in php?

953


Why overriding is called runtime polymorphism?

972


What is abstraction php?

970


How can a cross-site scripting attack be prevented by php?

979


What is a namespace in php?

944


Is it possible to submit a form with a dedicated button?

912


What is list in PHP?

1095


What are the string functions in php?

958


Do you know what are traits?

997


where do we use htaccess?

985


Which function would you use to format date information in php?

968


How many types of php frameworks are there?

910