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?

Answers were Sorted based on User's Feedback



How can I reset an array in PHP? ..

Answer / 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

How can I reset an array in PHP? ..

Answer / ram

The reset () function moves the internal pointer to the
first element of the array. This function returns the value
of the first element in the array on success, or FALSE on
failure.
Syntax: reset(array)

<?php
echo date("Y-m-d");
$people = array("Prasad", "Ram", "vidhya");

echo current($people) . "<br />";
echo next($people) . "<br />";

echo reset($people);
?>

Is This Answer Correct ?    10 Yes 1 No

How can I reset an array in PHP? ..

Answer / madipally

Its very simple uday,

we have an array of numbers , which contains
"Item1","Item2","Item3".

when we call next($numbers) , the pointer will be jump to
the next item, in this case Item2.After resetting using
reset($numbers) pointer will move to the first location that
is "Item1".

Is This Answer Correct ?    7 Yes 4 No

How can I reset an array in PHP? ..

Answer / uday

hello ur answer is too difcult to learn plz answer in
simple very complicated

Is This Answer Correct ?    3 Yes 11 No

Post New Answer

More PHP Interview Questions

What are the Formatting and Printing Strings available in PHP?

0 Answers  


What are helpers in php?

0 Answers  


Which function you can use in php to open a file for reading or writing or for both?

0 Answers  


Do you know when sessions ends?

0 Answers  


please send me the interview questions and answers to my mail id : srikanthgovardana@yahoo.com or srikanthgovardana@gmail.com

0 Answers  


What does PHP stand for?

7 Answers  


What is orm in php framework?

0 Answers  


I need to know about the courses which are useful in corporate companies.. especially php/mySQL, Java/j2ee, .NET.. also tell if any other courses are valuable

0 Answers  


List out some tools through which we can draw E-R diagrams for mysql?

6 Answers  


Which is not a php magic constant?

0 Answers  


What is an operator in php?

0 Answers  


Why do we use namespace in php?

0 Answers  


Categories