3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrays = json_decode('[ { "id": 0, "title": "a title" }, { "id": 1, "title": "another title" }, { "id": 2, "title": "one more title" } ]', true); $array = [ 'id' => 1, 'title' => 'a different title', ]; foreach ($arrays as &$value) { if ($value['id'] === $array['id']) { $value = $array; } } unset($value); var_dump($arrays);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(2) { ["id"]=> int(0) ["title"]=> string(7) "a title" } [1]=> array(2) { ["id"]=> int(1) ["title"]=> string(17) "a different title" } [2]=> array(2) { ["id"]=> int(2) ["title"]=> string(14) "one more title" } }

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:
52.16 ms | 401 KiB | 8 Q