3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $json = '{ "device" : [{ "id" : "18496597", "clientDeviceId" : "18", "name" : "Adven", "state" : 1, "statevalue" : "0", "methods" : 3, "type" : "device", "client" : "2612195", "online" : "1", "editable" : 1, "ignored" : 0 }, { "id" : "18327685", "clientDeviceId" : "7", "name" : "Alla", "state" : 1, "statevalue" : null, "methods" : 3, "type" : "group", "client" : "261295", "online" : "1", "editable" : 1, "ignored" : 0 } ] }'; $devices = json_decode($json); var_dump($devices); foreach ($devices->device as $device) { echo $device->name . ' - '. $device->state . PHP_EOL; } echo json_last_error();
based on 8LZos
Output for 7.0.0 - 7.3.0beta1
object(stdClass)#3 (1) { ["device"]=> array(2) { [0]=> object(stdClass)#1 (11) { ["id"]=> string(8) "18496597" ["clientDeviceId"]=> string(2) "18" ["name"]=> string(5) "Adven" ["state"]=> int(1) ["statevalue"]=> string(1) "0" ["methods"]=> int(3) ["type"]=> string(6) "device" ["client"]=> string(7) "2612195" ["online"]=> string(1) "1" ["editable"]=> int(1) ["ignored"]=> int(0) } [1]=> object(stdClass)#2 (11) { ["id"]=> string(8) "18327685" ["clientDeviceId"]=> string(1) "7" ["name"]=> string(4) "Alla" ["state"]=> int(1) ["statevalue"]=> NULL ["methods"]=> int(3) ["type"]=> string(5) "group" ["client"]=> string(6) "261295" ["online"]=> string(1) "1" ["editable"]=> int(1) ["ignored"]=> int(0) } } } Adven - 1 Alla - 1 0
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0
object(stdClass)#1 (1) { ["device"]=> array(2) { [0]=> object(stdClass)#2 (11) { ["id"]=> string(8) "18496597" ["clientDeviceId"]=> string(2) "18" ["name"]=> string(5) "Adven" ["state"]=> int(1) ["statevalue"]=> string(1) "0" ["methods"]=> int(3) ["type"]=> string(6) "device" ["client"]=> string(7) "2612195" ["online"]=> string(1) "1" ["editable"]=> int(1) ["ignored"]=> int(0) } [1]=> object(stdClass)#3 (11) { ["id"]=> string(8) "18327685" ["clientDeviceId"]=> string(1) "7" ["name"]=> string(4) "Alla" ["state"]=> int(1) ["statevalue"]=> NULL ["methods"]=> int(3) ["type"]=> string(5) "group" ["client"]=> string(6) "261295" ["online"]=> string(1) "1" ["editable"]=> int(1) ["ignored"]=> int(0) } } } Adven - 1 Alla - 1 0