FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » while into while
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: while into while [message #176185 is a reply to message #176184] Wed, 30 November 2011 14:44 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
monsieur madame wrote:
> Hi,
>
> I need some help with multiple while loops.
>
> I need to set a variable about the count of loops I want.
>
> For example, $i = 3; would do :
>
> while($x[$i-2] < 1) {
> while($x[$i-1] < 1) {
> while($x[$i] < 1) {
> ...
> }
> }
> }
>
>
> and $i = 2 would do :
>
> while($x[$i-1] < 1) {
> while($x[$i] < 1) {
> ...
> }
> }
>
>
>
> I can't find how to do it. I'm pretty sure I miss a small magic
> trick....
>
> If someone have an idea... Thanks


I have an idea that's probably beyond most procedural languages..as a
straight coding exercise BUT you MAY be able to do it as a recursive call

Consider the following

function loopy($i)
{
while ($i && (something else))
{
// do your loopy stuff.
}
$i--;
if($i>0)
$i=loopy($i);
return $i;
}


That will exercise the same loop $i times.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Browser doesn't support
Next Topic: PHP-HTML-Javascript opportunities with Yahoo R&D!!!
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 15:40:46 GMT 2024

Total time taken to generate the page: 0.04076 seconds