LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Matt Neimeyer Date: Fri May 9 10:03:17 2008 Subject: Re: Recursion... Sort of...
Wow! Thanks guys! Here's what I ended up doing... To get...
Black on White - 1
White on Black - 2
Black on White - 3
Black on White - 3
White on Black - 2
Black on White - 3
I had to do something like...
function doStuff()
{
static $callCount = 0;
$callCount++;
if($callCount%2)
{ echo 'white on black - '.$callCount; }
else
{ echo 'black on white - '.$callCount; }
// Stuff that uses the depth count
$callCount--;
}
If I didn't put in the $callCount--; I ended up with something like this...
Black on White - 1
White on Black - 2
Black on White - 3
White on Black - 4
Black on White - 5
White on Black - 6
I saw where it was said that "oh he said it wasn't recursive"... Sorry
I wasn't clearer. In my mind a "true" recursive function is a function
that operates on it's own output like a factorial... Not just a
function that is called inside itself.
This got me where I needed to be and it is GREATLY appreciated!
Matt
| Navigate in group php.general at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |