Page 1 of 1

PHP v.4.0.6 and recursion is it PHP or my code?

Posted: Wed Dec 29, 2004 5:00 pm
by carlmcdade
Before I go banging my head against the wall and drinking too much coffee I thought I would ask to see if I am just not seeing my smistake or does this version of PHP have a bug or limitaion.

Thanks for any input.

Code: Select all

<?php
function text ($value){
	if (is_array($value)){

		foreach($value as $k=>$v){
			if (is_array($v)){

				return text($v);

			}else{

				$output .= $label[$i].'<br>'."\n";
				$output .= '<input id="" name="'.$label[$i].'" type="text" value="'.$v.'">'."\n";
			}
		}
		return $output;
	}else{
		$output .= $label[$i].'<br>'."\n";
		$output .= '<input id="" name="'.$label[$i].'" type="text" value="'.$value.'"><br>'."\n";
		return $output;
		}
}
print text($value[$i]);?>

Code: Select all

Fatal error: Cannot redeclare text() in /home/.sites/125/site219/web/site/kwiki_includes/common.php on line 47
return text($v); is line 47

Posted: Wed Dec 29, 2004 5:35 pm
by rehfeld
u sure you didnt define it twice, or maybe have the definition in a loop or a file thats included more than once?

that is kinda odd how it points to line 47 though...

Posted: Wed Dec 29, 2004 6:38 pm
by adamus
I tested on version 4.3.3 and it is working.

why not trying use other name instead of text?

Posted: Wed Dec 29, 2004 7:06 pm
by carlmcdade
rehfeld wrote:u sure you didnt define it twice, or maybe have the definition in a loop or a file thats included more than once?

that is kinda odd how it points to line 47 though...
That was it!!! I am tired and did not see a loop higher up in the code. I was thinking that the was protection against in the if stament. But as it turns out the if statement returned true once too many.

Thanks