Re: Simple @#%@#% array/function not working....
| From: | David Robley | Date: | Tue, 13 May 2003 01:05:47 +0000 |
| Subject: | Re: Simple @#%@#% array/function not working.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147384@lists.php.net to get a copy of this message | ||
In article <005f01c317c7$802c6630$1701400a@l2zcaxu7emppqh>, ryan@jumac.com
says...
> Hi,
> Am kind of new to php and brand new to arrays so please excuse me if this is
> a stupid way of doing things.
>
> I have an array and its working fine, but when i try to call a function that
> checks if the array isset i dont get the required output.
> Heres the code below:
>
> if (is_array($id)) { print "<pre>\$id = "; print_r($id); print
> "</pre>\n"; } //working fine
> $result = count ($id); //working fine
> print($result); //working fine
>
> function one()
> {
> if(isset($id[0]))
> return("test=".$id[0]);
> }
> echo "<h1>testing".one()."</h1>"; //HERES the problem, this is
> only
> printing "testing" instaed of "testing(array value)"
>
>
> Any ideas?
Yes. To access the value of $id[] in the function you either need to pass
it as a parameter to the function, or declare it global in the function.
Then you might want to assign the return from the function to a variable
which you then echo.
You might want to read up on the scope of variables in the manual.
--
Quod subigo farinam
$email =~ s/oz$/au/o;