3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function objectToArray($input) { $arrayObject = new ArrayObject($input); //die(print_r($arrayObject)); //foreach($arrayObject as $key => $val) { //if (!is_object($val)) { // continue; //} //$arrayObject[$key] = objectToArray($val); //} //return $arrayObject; } $object = json_decode('{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}'); $array = objectToArray($object);
based on eCCCl
Output for 5.6.0 - 7.3.0alpha1