How can I reset an array in PHP?
This is easily done with the reset function, like this:
This returns the first element and sets it as the current element.
Here is a little example just to make this technique clear:
$numbers = array("Item 1","Item 2","Item 3");
$thisvalue = current($numbers); echo "We are now at $thisvalue\n\n";
$first = reset($numbers);
echo "Back to $first";
We are now at Item 2
Back to Item 1
More arrays PHP QuestionsHow do we sort an array of names taken from a text file, displaying only unique names?
to check if the value is an array
how can you reset an array in PHP
How do I turn an array into a string?
I have an array of numbers and many repeat, how to list all items in order of maximum occurence?