Re: Recursion... Sort of...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux