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

What is the best php framework 2018?

947


How to close a session properly?

924


What is the difference between the include() and require() functions?

1414


What is the difference between $argv and $argc? Give example?

920


Write a program to show the joining of two strings in php?

910


How to reset/destroy a cookie in php?

929


How to read a file in php?

914


Explain type casting and type juggling.

984


Tell me which function gives us the number of affected entries by a query?

969


Php error constants and their descriptions

1112


How to create a mysql connection?

919


What is difference between rest api and restful api?

928


Who is the father or inventor of php?

1028


Does php have multiple inheritance?

935


Why overriding is called runtime polymorphism?

928