RE: [PHP] function not returning value
| From: | Martin Towell | Date: | Wed, 01 May 2002 02:30:05 +0000 |
| Subject: | RE: [PHP] function not returning value | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-95470@lists.php.net to get a copy of this message | ||
you're only returning the value, and not setting the global variable
you could place a "global $handle_guess:" as the first line of your function
or you could do "$handle_guess = get_handle($lastname, $firstname);"
-----Original Message-----
From: Mark Pelillo [mailto:pelillom@earthlink.net]
Sent: Wednesday, May 01, 2002 12:09 PM
To: PHP help
Subject: [PHP] function not returning value
Why would the following function not return a value: (both $lastname and
$firstname are defined)
function get_handle($lastname, $firstname)
{
$handle_guess=$lastname;
$handle=array();
$fp=fopen('../truelies/userdb', "r");
while ($d=fgetcsv($fp, 250, ";")) {
$handle[] = $d[0];
}
fclose ($fp);
for ($i=0; $i<count($handle); $i++) {
if (strcmp($handle_guess, $handle[$i]) ==0) {
$j=1;
$handle_guess = $handle_guess . substr
($firstname,0,$j);
$j++;
}
}
return $handle_guess;
}
if I put an echo $handle_guess before or after the function then
nothing. So far the only way to make it work is
echo get_handle($lastname, $firstname);
which is not beautiful.
BTW is there a limit to the length of a command. If I can't figure this
out then I will have five or six of this "echo" statement concatanated
together.
Mar
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php