3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jsons[] = <<<JSON { "success": true, "msg": "", "obj": [ { "id": 1, "remark": "D" }, { "id": 159, "remark": "mssdss" } ] } JSON; $jsons[] = <<<JSON { "success": true, "msg": "", "obj": [ { "id": 14, "remark": "tttt" }, { "id": 56, "remark": "ok" } ] } JSON; $result = null; foreach ($jsons as $json) { $obj = json_decode($json); if (!$obj->success) { throw new Exception($obj->msg); } if (!$result) { $result = $obj; } else { array_push($result->obj, ...$obj->obj); } } var_export($result);
Output for rfc.property-hooks, git.master_jit, git.master
(object) array( 'success' => true, 'msg' => '', 'obj' => array ( 0 => (object) array( 'id' => 1, 'remark' => 'D', ), 1 => (object) array( 'id' => 159, 'remark' => 'mssdss', ), 2 => (object) array( 'id' => 14, 'remark' => 'tttt', ), 3 => (object) array( 'id' => 56, 'remark' => 'ok', ), ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.03 ms | 1159 KiB | 4 Q