|
Posted by robert on 05/04/06 23:48
"gerg" <noemail@noemail.com> wrote in message
news:Fa-dnZRMT8TTxsfZ4p2dnA@comcast.com...
| 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.
np...glad it makes sense for you now.
l8r.
Navigation:
[Reply to this message]
|