Re: function not returning value
| From: | Evan Nemerson | Date: | Wed, 01 May 2002 03:04:09 +0000 |
| Subject: | Re: function not returning value | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95474@lists.php.net to get a copy of this message | ||
http://www.php.net/manual/en/language.variables.scope.php
On Tuesday 30 April 2002 19:09 pm, you wrote:
> 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
--
He who learns must suffer.
Aeschylus