Re: the numeric key of an array???
| From: | Alexander Guevara | Date: | Sat, 21 Dec 2002 02:05:47 +0000 |
| Subject: | Re: the numeric key of an array??? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129043@lists.php.net to get a copy of this message | ||
Well which kind of methods are you talking about?? could you tell me some
for do it??
Thanks!
"John W. Holmes" <holmes072000@charter.net> wrote in message
news:000001c2a890$d1539cf0$7c02a8c0@coconut...
> > How can i do for printing the value of an array given the numeric key
> for
> > example i have this code:
> >
> > $array = array (
> > 'VAL1' => "VALUE1",
> > 'VAL2' => "VALUE2",
> > 'VAL3' => "VALUE3"
> > )
> >
> > So the only way i have found to print the value is like this :
> > echo $array['VAL1'];
> >
> > and it prints = VALUE1 but i want to know if its possible to do it
> > something
> > like this:
> > echo $array[0];
> > i mean give the numeric key for printing VALUE1 so instead the string
> key
> > (VAL1) use the numerc (0)
>
> You can't, because there is no key of zero in that array. All arrays are
> associative, so the only way to use $array[0] is to define $array[0].
>
> If you're looking to loop through your array, there are other methods.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>