Re: OK ... WHY does this work ?????

From: Date: Tue, 14 Sep 2004 21:13:20 +0000
Subject: Re: OK ... WHY does this work ?????
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-196662@lists.php.net to get a copy of this message
On Tue, 14 Sep 2004 22:32:54 +0200, -{ Rene Brehmer }- <metalbunny@metalbunny.net> wrote: > Unless I misunderstand how PHP make unspecified arrays (and I probably do > since this works), when you have an array of 3 elements on the first > dimenstion like I do, and then ask for $arrlevels[$lvl_guest]['levelname'], > which in this case actually means it asks for $arrlevels[99]['levelname'] > .... how come it pick the correct element, and not error out that element > 99 don't exist ?? > > My only conclusion (based on the fact that this actually works) is that PHP > makes the key the same as the value if the key isn't specified. But is this > actually correct ???? Or is there something "going on" that I don't know > about ??? Yes, that is what's happening, a simple test shows this: #!/usr/bin/php <?php $a = array(1, 2, 3); print_r($a); ?> output: Array ( [0] => 1 [1] => 2 [2] => 3 ) -- Greg Donald http://destiney.com/

« previous php.general (#196662) next »