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

From: Date: Fri, 09 Mar 2001 23:15:07 +0000
Subject: Re: note 11857 added to language.types.array.php
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-12137@lists.php.net to get a copy of this message
jeroen@nospam.a-eskwadraat.nl writes: > Named indeces > > These are equal: > a) $arr[foo] = "bar" > b) $arr['foo'] = "bar" > c) $arr["foo"] = "bar" No, they're actually not. For instance, try this: $arr[default] = 'bar'; $arr['default'] = 'bar'; ...only the second one works. *Always* use quotes for string array indices...I suppose we should mention this somewhere in the manual. > But there are not > a) echo "Value is $arr[foo]" > b) echo "Value is $arr['foo']" > c) echo "Value is $arr[\"foo\"]" > > (only (a) works, b and c do NOT work, in fact, they give a VERY strange error) > > http://www.php.net/manual/en/language.types.array.php This does need to mentioned in the manual. -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Adcore Finland| |http://www.coastnet.com/~torben http://www.adcore.com| |Ph: 1.604.709.0506 torben@adcore.com| +----------------------------------------------------------------+

« previous php.notes (#12137) next »