Rewind foreach loop
- From: jeffery@xxxxxxxxxx (Jeffery Fernandez)
- Date: Fri, 30 Nov 2007 13:55:59 +1100
Hi all,
Is it possible to rewind a foreach loop? eg:
$numbers = array(0,1,2,3,4,5,6,7,8,9,10);
foreach ($numbers as $index => $value)
{
if ($value == 5)
{
prev($numbers);
}
echo "Value: $value" . PHP_EOL;
}
The above doesn't seem to work. In one of my scenarios, when I encounter and
error in a foreach loop, I need the ability to rewind the array pointer by
one. How can I achieve this?
regards,
Jeffery
--
Internet Vision Technologies
Level 1, 520 Dorset Road
Croydon
Victoria - 3136
Australia
web: http://www.ivt.com.au
phone: +61 3 9723 9399
fax: +61 3 9723 4899
.
- Follow-Ups:
- Re: [PHP] Rewind foreach loop
- From: Jim Lucas
- Re: [PHP] Rewind foreach loop
- From: Jochem Maas
- Re: Rewind foreach loop
- From: ZeldorBlat
- Re: [PHP] Rewind foreach loop
- From: Chris
- Re: [PHP] Rewind foreach loop
- Prev by Date: Re: [PHP] Join question
- Next by Date: Re: [PHP] Join question
- Previous by thread: Calling parent function with call_user_func_array
- Next by thread: Re: [PHP] Rewind foreach loop
- Index(es):
Relevant Pages
|
|