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 #176192 is a reply to message #176184] Wed, 30 November 2011 16:01 Go to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Wed, 30 Nov 2011 06:36:00 -0800, monsieur madame wrote:


> 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

Recursive function, something like (untested):

function recurseWhile ($x, $i)
{
while($x[$i-($i - 1)] < 1)
{
if ($i != 0)
{
recurseWhile ($x, $i - 1)
}
else
{
...
}
}
}

Rgds

Denis McMahon
[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: Fri Sep 20 12:52:32 GMT 2024

Total time taken to generate the page: 0.04793 seconds