Re: Arrays help please
| From: | Chris | Date: | Tue, 25 Jul 2000 23:53:49 +0000 |
| Subject: | Re: Arrays help please | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8168@lists.php.net to get a copy of this message | ||
Yes,
You are correct, the problem was farther up where I was filling the array, I
was actually filling the array as:
array(0=>array("bob"),1=>array("male,"27"));
which is wrong.
> Uhh yes..
>
> http://php.net/manual/ref.array.php
> http://php.net/manual/language.types.array.php
>
> Make sure you prepend your variable names with $.
>
> $myarray = array ("bob" => array ("male", "27"));
> echo $myarray[bob][0];
>
> That will print `male'.
>
> --
> Eden Li
> eden@adv-computer.com
>
> -----Original Message-----
> How can I refer to an array using a value instead of a number?
> Ex:
> I have a 2 dimensional array like myarray =
array("bob"=>array("male","27"),
> etc etc)
> I want to refer to the array values like this:
> echo myarray["bob"][0] => would print "male". Instead of having to do
> it
> like:
> echo myarray[0][0]