Nested associative array as object
<p>I'm trying to access a nested associative array
as object</p>

<pre><code>function multiArrayToObject(array $array){

   if(!is_string(key($array))){
        throw new Exception('Invalid associative array'); 
    }
    $root = new ArrayObject($array,ArrayObject::ARRAY_AS_PROPS);
    foreach($array as $value){
       if(is_array($value)){
            multiArrayToObject($value);
       }
       else{
            return $root;
       }
    }
    return $root;
}

$array = array('user' =&gt; array('data'=&gt;array('name'=&gt;'bob')));


$data = multiArrayToObject($array);



var_dump($data-&gt;user-&gt;data);
</code></pre>

<p>but it doesn't work.</p>

<p>Could you help me, please ?</p>

<p>Thanks in advance.</p>
