|
Posted by gerg on 05/04/06 12:55
Hello, I have a question about how a function returns a value.
I have written the following code:
<?
function explodeit($var){
return explode( ", " , $var );
}
function echoarray($var){
foreach( $var as $name ){
echo "$name<br><br>";
}
}
$string = "Peter, Paul, Mary";
$names = explodeit($string);
$db = echoarray($names);
if (!$db){ echo "Problem"; }
?>
This code results in the following:
Peter
Paul
Mary
Problem
If you edit this line:
if (!$db){ echo "Problem"; }
to this:
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?
- Greg
Navigation:
[Reply to this message]
|