Re: array key's: which is correct?
| From: | Ashley Sheridan | Date: | Tue, 08 Jun 2010 13:30:27 +0000 |
| Subject: | Re: array key's: which is correct? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305951@lists.php.net to get a copy of this message | ||
On Tue, 2010-06-08 at 16:12 +0300, Tanel Tammik wrote:
> Hi,
>
> which one is correct or "better"?
>
> $array[3] = '';
> or
> $array['3'] = '';
>
> $i = 7;
>
> $array[$i] = '';
> or
> $array["$i"] = '';
>
>
> Br
> Tanel
>
>
>
The two indexes are equivalent, although I reckon the integer one will
give better performance over the string.
Thanks,
Ash
http://www.ashleysheridan.co.uk