Re: Recursion... Sort of...

From: Date: Fri, 09 May 2008 16:03:17 +0000
Subject: Re: Recursion... Sort of...
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-274077@lists.php.net to get a copy of this message
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

« previous php.general (#274077) next »