RE: [PHP] A problem with associative arrays..

From: Date: Wed, 26 Jul 2000 20:59:30 +0000
Subject: RE: [PHP] A problem with associative arrays..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8409@lists.php.net to get a copy of this message
> Woah! PHP can do this? Since what version? As far as I knew, > you needed to use substr() to get even 1 character from a string. > This is too cool. Since forever. This was added to the early days of PHP 3 > > > $conf['db'] = "testdb"; > > > $conf['db']['host'] = "dbhost"; > > He's not defining it as a string. He's accessing it as an array. > Does it still apply? What if he defined $conf to be an array > prior to this? Think of it this way: $conf['db'] = "testdb"; Now, when you try to assign something to $conf['db']['host'] the $conf['db'] part is "testdb", what would "testdb"['host'] be? Since $cond['db'] is a string, the 'host' index of this string is the same as "testdb"[0] which is the first position of the string. So when you do: $conf['db']['host'] = "dbhost"; You end up with, "destdb", because there is only room for the first character of "dbhost" in the $conf['db'][0] slot. -Rasmus

« previous php.general (#8409) next »