3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json1 = '{ "d": [{"A": 0,"B": "foo1","C": "bar1","D": "real1","E": 0}, {"A": 1,"B": "foo2","C": "bar2","D": "real2","E": 1}, {"A": 2,"B": "foo3","C": "bar3","D": "real3","E": 2} ] }'; $json2 = '{ "A": ["this1","this2","this3"], "E": ["last1","last2","last3"] }'; $array1 = json_decode($json1, true); $array2 = json_decode($json2, true); foreach ($array1['d'] as &$arr) { foreach ($arr as $key => &$value) { if (array_key_exists($key, $array2)) { $value = $array2[$key][$value]; } } } echo json_encode($array1, JSON_PRETTY_PRINT);
Output for git.master, git.master_jit, rfc.property-hooks
{ "d": [ { "A": "this1", "B": "foo1", "C": "bar1", "D": "real1", "E": "last1" }, { "A": "this2", "B": "foo2", "C": "bar2", "D": "real2", "E": "last2" }, { "A": "this3", "B": "foo3", "C": "bar3", "D": "real3", "E": "last3" } ] }

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:
196.94 ms | 406 KiB | 5 Q