I have a function like:
myfunction($i,$condition = false, $level = 0) {
do {
if (... some conditions here) { myfunction($i, true, ++$level) }
else { do something here ... }
while ( ...meet ending condition )
}
I don't understand why the $condition turn true when i call myfunction() recursively and come back to false when iterating in first level and $level won't turn to 0 after it exits a recursive mode.
$condition = false, false, true, false, false, true, true, true ...
$level = 0,0,1,1,1,2,2,2 ... it shoul also be like = 0,0,1,0,0,1,2,2,2,0 ... and so on
?
Thank you
P.S : It is the same with arrays ? I declared an array in the function set to null and when exits the recursive mode it's not null anymore :
myfunction($i,$condition = false, $level = 0, $array = null) {
do {
if($condition) { $array = null } <--------- I HAVE TO ADD THIS LINE TO MAKE IT NULL WHY ?
if (... some conditions here) {$array = Array(someblabla); myfunction($i, true, ++$level, $array) }
else { do something here ... }
while ( ...meet ending condition )
}