Re: Is there a 'redo' loop control function?
| From: | Jason Murray | Date: | Thu, 01 Feb 2001 17:42:06 +0000 |
| Subject: | Re: Is there a 'redo' loop control function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-37655@lists.php.net to get a copy of this message | ||
John Luxford wrote:
>
> Hello
>
> Is there a 'redo' loop control function? All I can find are 'break' and
> 'continue'.
>
> Thanks
>
> Lux
>
Hi,
Here's one way:
for ($nr = 0; $nr < 5; $nr++) {
if ($arr[$nr] == "foo") {
$arr[$nr] = "bar"; /* otherwise it's infinite */
--$nr;
continue;
}
}
By the way, This is not considered a Good Thing by anyone I know. Mostly
it is just a waste of time--is it really necessary to do this? Not in
this case, but it's just an illustration. Otherwise, if you are not
careful, you'll get infinite loops or some other wierdness.
Regards,
Jason
--
Jason Murray
Developer
http://www.jwebmedia.com/
1 877 525 jWEB