ID: 41682 Updated by: [EMAIL PROTECTED] Reported By: acallaha at connect dot carleton dot ca -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: Fedora PHP Version: Irrelevant New Comment:
This is expected behavior for ArrayObject:offsetGet(). The array in your reproduce code has only associative keys, so there is no value at the integer index 2: $ php <?php $array_3=array("this"=>"0", "is"=>"1", "life"=> "hello"); $array_3_obj = new ArrayObject($array_3); print $array_3_obj->offsetGet(2)."\n"; print $array_3_obj->offsetGet("is")."\n"; $array_4_obj = new ArrayObject(array("0","1","hello")); print $array_4_obj->offsetGet(2)."\n"; ?> ^D Notice: Undefined offset: 2 in - on line 4 1 hello $ If you truly want the third element of an associative array regardless of key, you may be looking for ArrayIterator. Previous Comments: ------------------------------------------------------------------------ [2007-06-13 18:58:40] acallaha at connect dot carleton dot ca Description: ------------ ArrayObject::offsetGet() does NOT return the value corresponding to a given index as documented, but actually requires a key (NOT an int $index) as input and returns a value given this key. This was determined through testing. Reproduce code: --------------- A sample array: $array_3=array("this"=>"0", "is"=>"1", "life"=> "hello"); $array_3_obj = new ArrayObject($array_3); print $array_3_obj->offsetGet(2); Expected result: ---------------- hello Actual result: -------------- PHP Notice: Undefined offset: 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41682&edit=1