You are here: functions returning false « All PHP « IT news, forums, messages
functions returning false

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация