Re: note 13888 added to language.types.array.php

From: Date: Sun, 08 Jul 2001 20:06:17 +0000
Subject: Re: note 13888 added to language.types.array.php
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-15098@lists.php.net to get a copy of this message
1) it is in the manual 2) it DOES work (if not, there's a bug somewhere...) Jeroen ----- Original Message ----- From: <stefan@php2.chek.com> Newsgroups: php.notes To: <php-notes@lists.php.net> Sent: Sunday, July 08, 2001 7:06 PM Subject: note 13888 added to language.types.array.php > If using associative arrays with strings as keys, I would recommend explicitly quoting the keys, i.e. use $array["$key"] instead of $array [$key]. You might run into trouble with PHP not finding your array elements if $key is numeric but meant to be an associative key because PHP would interpret $array [$key] as an access to an indexed array. By quoting you kind of type cast the key to a string. > > I'll give an example to clarify: > Define > $a ["abc"] = "one"; > $a ["234"] = "two"; > Now try: > print $a ["abc"] works as expected > print $a ["234"] works as expected > but print $a [234] will *not* > > Maybe this should be added to the manual somewhere. > > Steve > > http://www.php.net/manual/en/language.types.array.php >

« previous php.notes (#15098) next »