fork download
  1. <?php
  2.  
  3. $array = [
  4. 'test1' => ['name' => 'alex', 'text' => 'sometext', 'attr' => [
  5. 'attr1' => 'sex',
  6. 'attr2' => 'height',
  7. 'attr3' => 'weight',
  8. ],
  9. ],
  10. 'test2' => ['name' => 'alex', 'text' => 'sometext'],
  11. 'test3' => ['name' => 'alex', 'text' => 'sometext'],
  12. ];
  13.  
  14. // your code goes here
  15. $object = json_decode(json_encode($array), FALSE);
  16.  
  17. echo $object->test1->attr->attr1;
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
sex