Re: PHP problem with array keys / pointers
| From: | Robert Cummings | Date: | Sun, 17 Dec 2006 23:27:11 +0000 |
| Subject: | Re: PHP problem with array keys / pointers | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-245933@lists.php.net to get a copy of this message | ||
On Sun, 2006-12-17 at 23:19 +0000, julian haffegee wrote:
> > will set the element of ordinal number 0 and key ' 2' to 'dog'. To
> > get
> > that value you would either ask for $array[0] or $array[' 2'].
>
>
> thanks for all the comments so far, i'm not sure you are understanding what
> I am asking for.
> My problem is NOT knowing what is in the arrays, but how to access them.
>
> My ordial number/key is a variable, and I need to sometimes use it as a key,
> and sometimes as an ordial
>
> so I need 2 ways of writing $array[$x],
>
> one being equivalent to $array[0] - $x is treated as an integer
> and one being equivalentt to $array['0'] - $x is treated as a string
$array['0'] and $array[0] are identical in PHP. The string '0' will be
automatically juggled to an integer when used as an index. You CANNOT
differentiate even if you want.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'