RE: [PHP] Passing arrays to functions
| From: | Maciek Uhlig | Date: | Tue, 01 Aug 2000 08:50:45 +0000 |
| Subject: | RE: [PHP] Passing arrays to functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9387@lists.php.net to get a copy of this message | ||
Did you declare $something as global inside your function foo? Remeber there
exists something like variable scope (see manual).
Maciek
> -----Original Message-----
> From: Jeff [mailto:php@biz-link.com]
> Sent: Tuesday, August 01, 2000 10:10 AM
> To: Soeren Staun-Pedersen
> Cc: PHP General List
> Subject: Re: [PHP] Passing arrays to functions
>
>
> I tried that but all the elements in $something were
> empty inside the function. For now I'll assume I screwed up
> something else and try it again...
>
> Jeff
>
>
>
> Soeren Staun-Pedersen wrote:
> >
> > On Tue, 1 Aug 2000, Jeff wrote:
> >
> > > Can I pass an array as an argument to a function?
> > >
> > > The function call <? echo foo($bar[]) ?> works fine, but
> > > the function declaration function foo($bar[]) gives
> > > a compile time error in php3 - "expected )".
> > >
> > > Someone please tell me what I did wrong.
> >
> > function foo($something)
> > {
> > echo gettype($something);
> >
> > }
> >
> > $a = array(1,2,3,4);
> >
> > foo($a);
> >
> > ->"array"
> >
> > Soeren Staun-Pedersen - staun@netwarriors.org
> > ------
> > "The internet is full, beat it"
> > - Me.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>