| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2005-06-26 10:56 UTC] helly@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 08:00:01 2025 UTC | 
Description: ------------ Object implements ArrayAccess. First to make multi-dimension arrays i've been told there was a bug and I had to put by reference &offsetGet($offset) for that function. After that my multi-dimension arrays were working. Secondly it appears to ALWAYS, whatever I tried, to return a E_NOTICE when the second index of the array doesnt exists but the first one do exists. [index3 example] Thirdly when the second index doesnt exists and you are trying to fetch the third thru the second index and first index exists it seems to be returning the first lettre from the value of the last existing index...[index4 example] How can I check the second, third, fourth, etc... array index when all I get is $offset as a string or only one parameter... Reproduce code: --------------- <?php ini_set("display_errors", "On"); error_reporting(E_ALL); class Data{ public static $myArray = array(); final function __construct(){} final function __destruct(){} final function __clone(){} } class test implements ArrayAccess{ function offsetExists($index){ if (isset(Data::$myArray[$index])) return TRUE; return FALSE; } function &offsetGet($index){ if (isset(Data::$myArray[$index])) return Data::$myArray[$index]; $index = FALSE; return $index; } function offsetSet($index, $value){ Data::$myArray[$index] = $value; } function offsetUnset($index){ Data::$myArray[$index] = NULL; } } $test = new test(); $test['index1'] = array(); $test['index1']['test1'] = 'test2'; $test['index1']['index2'] = 'xest3'; $test['test4'] = 'test5'; echo $test['test4']; echo $test['index1']['index3']; echo $test['index1']['index2']['index4']; echo $test['index5']; ?> Expected result: ---------------- test5 Actual result: -------------- test5 Notice: Undefined index: index3 in /path/file.php on line 36 x