3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data_json = '{ "EXPORT": [ { "dates": "2019-07-01", "c_job": 12 }, { "dates": "2019-07-02", "c_job": 8 }, { "dates": "2019-07-04", "c_job": 11 } ], "IMPORT": [ { "dates": "2019-07-03", "c_job": 11 } ] }'; $blank_json = '[ { "dates": "2019-07-01", "c_job": 0 }, { "dates": "2019-07-02", "c_job": 0 }, { "dates": "2019-07-03", "c_job": 0 }, { "dates": "2019-07-04", "c_job": 0 } ]'; $data = json_decode($data_json, true); $blank = json_decode($blank_json, true); $datafinal = array(); foreach ($data as $key => $value) { foreach ($blank as $bkey => $bvalue) { if (($dkey = array_search($bvalue['dates'], array_column($value, 'dates'))) !== false) { $datafinal[$key][$bkey] = $value[$dkey]; } else { $datafinal[$key][$bkey] = $bvalue; } } } echo json_encode($datafinal, JSON_PRETTY_PRINT);
Output for git.master, git.master_jit, rfc.property-hooks
{ "EXPORT": [ { "dates": "2019-07-01", "c_job": 12 }, { "dates": "2019-07-02", "c_job": 8 }, { "dates": "2019-07-03", "c_job": 0 }, { "dates": "2019-07-04", "c_job": 11 } ], "IMPORT": [ { "dates": "2019-07-01", "c_job": 0 }, { "dates": "2019-07-02", "c_job": 0 }, { "dates": "2019-07-03", "c_job": 11 }, { "dates": "2019-07-04", "c_job": 0 } ] }

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:
27.06 ms | 407 KiB | 5 Q