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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
carlmcdade
Forum Newbie
Posts: 24
Joined: Thu Dec 02, 2004 2:19 am
Location: sweden

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

Post 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
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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...
adamus
Forum Newbie
Posts: 5
Joined: Wed Dec 29, 2004 6:30 pm
Contact:

Post by adamus »

I tested on version 4.3.3 and it is working.

why not trying use other name instead of text?
User avatar
carlmcdade
Forum Newbie
Posts: 24
Joined: Thu Dec 02, 2004 2:19 am
Location: sweden

Post 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
Post Reply