3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $requestResult = <<<EOT { "name": "Benjamin Clementine", "mbid_id": "578e5d1c-be21-4158-b147-30aad67f207d", "albums": { "68e65535-f133-408d-93dd-205e9555eaa5": { "albumcover": [ { "id": "172070", "url": "http://assets.fanart.tv/fanart/music/578e5d1c-be21-4158-b147-30aad67f207d/albumcover/at-least-for-now-55b74dfa59411.jpg", "likes": "0" } ] } } } EOT; $decodedResult = json_decode($requestResult, true); $xmlELement = new SimpleXMLElement('<root/>'); array_walk_recursive($decodedResult, array($xmlElement, 'addChild')); print_r($xmlElement->xpath('//albumcover/url'));
based on NFC8N
Output for 7.0.5 - 7.2.0
Notice: Undefined variable: xmlElement in /in/7lWp3 on line 24 Warning: array_walk_recursive() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in /in/7lWp3 on line 24 Notice: Undefined variable: xmlElement in /in/7lWp3 on line 26 Fatal error: Uncaught Error: Call to a member function xpath() on null in /in/7lWp3:26 Stack trace: #0 {main} thrown in /in/7lWp3 on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: xmlElement in /in/7lWp3 on line 24 Warning: array_walk_recursive() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in /in/7lWp3 on line 24 Notice: Undefined variable: xmlElement in /in/7lWp3 on line 26 Fatal error: Uncaught Error: Call to a member function xpath() on unknown in /in/7lWp3:26 Stack trace: #0 {main} thrown in /in/7lWp3 on line 26
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined variable: xmlElement in /in/7lWp3 on line 24 Warning: array_walk_recursive() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in /in/7lWp3 on line 24 Notice: Undefined variable: xmlElement in /in/7lWp3 on line 26 Fatal error: Call to a member function xpath() on null in /in/7lWp3 on line 26
Process exited with code 255.
Output for 5.3.19 - 5.5.35
Notice: Undefined variable: xmlElement in /in/7lWp3 on line 24 Warning: array_walk_recursive() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in /in/7lWp3 on line 24 Notice: Undefined variable: xmlElement in /in/7lWp3 on line 26 Fatal error: Call to a member function xpath() on a non-object in /in/7lWp3 on line 26
Process exited with code 255.