[thelist] PHP - need clarification of quotes in array names.

Jeanne Pelletier jpellet at mediaone.net
Tue Feb 5 10:39:00 CST 2002


You could try
echo($foo['bar']." world");


----- Original Message -----
From: "Donald Noble" <donaldrnoble at yahoo.com>
To: <thelist at lists.evolt.org>
Sent: Tuesday, February 05, 2002 11:24 AM
Subject: [thelist] PHP - need clarification of quotes in array names.


> Hi, I'm quite new to PHP, and having a bit of trouble with Arrays,
>
> The manual says $foo[bar] is wrong, and appears to say I should use
> $foo['bar']. OK
> How then do I echo $foo['bar'] as part of a string? if I have:
> $foo['bar'] = "hello";
> echo "$foo['bar'] world";
> This gives an error.
> If I have
> $foo['bar'] = "hello";
> echo "$foo[bar] world";
> This works, but is it wrong?
> Or should I write
> $foo['bar'] = "hello";
> echo $foo['bar']." world";
> which is a bit more work.
>
> Is $foo[0] the correct way to access the first value in the array $foo? or
> does that need quotes too!
>
> Please help a very confused newbie,
> Cheers, Donald
>
> PS. Any links to pages on how to write clean efficient coding are much
> appreciated.
>
>
>
> ----------------------------------------------
>      http://www.AccessibleComputers.co.uk
>  Hardware, Software & Custom built PC Systems
> ----------------------------------------------
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list