in middle of my code i want to reset my array.

How It Works

Get an answer in three easy steps. Here's how it works...

Ask Your Question

1. Ask Your Question

Enter your PHP question at the top of this page and click Get An Answer.

Pick Your Priority

2. Pick Your Priority

Tell us how quickly you want your PHP question answered.

Get An Answer

3. Get An Answer

Connect with your programmer via online chat or telephone call.

Answer

Customer

in middle of my code i want to reset my array.

Posted
Albert Shohez
Programmer

You can do this 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"; 
?>
Posted
Customer

nice answer and thanks for the example.

Posted

quoteTestimonialsquote

About ExpertHelp

ExpertHelp is changing the way you connect with service professionals.

Whether you have a quick question while preparing your taxes, troubleshooting a computer problem, or need to hire an attorney, ExpertHelp is the most convenient and affordable way to connect with the right service professional to get the job done.

ExpertHelp has been in business since 2011, is an A+ Rated Better Business Bureau accredited member, and offers a 100% satisfaction guarantee on every question you ask!

More PHP Questions...

Ask Your PHP Question & Get An Answer Now!