|
Posted by gerg on 05/04/06 22:51
robert wrote:
> | function echoarray($var){
> |
> | foreach( $var as $name ){
> |
> | echo "$name<br><br>";
> |
> | }
> |
> | }
> |
> | if ($db){ echo "Problem"; }
> |
> | the result is:
> |
> | Peter
> |
> | Paul
> |
> | Mary
>
> | So I can't figure out how exactly, when the function does execute, I'm
> | still getting the error message. Any ideas?
>
> moments like this make me chuckle. ;^)
>
> echoarray() doesn't return anything! and, no matter what, it always echos
> data to the browser/output buffer. if you put "return true;" as the last
> executed line within the body of that function, then it would behave more
> like you're expecting.
>
> try this:
>
> function echoArray($array)
> {
> if (!is_array($array)){ return false; }
> echo implode("<br><br>\n", $array);
> return true;
> }
>
> hth,
>
> me
>
>
Robert, your the man. I had misunderstood how functions return a value.
Thanks for your input, works great now!
Thanks again.
Greg
Navigation:
[Reply to this message]
|