3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{"REG":"SK", "RES":"PAN1", "WELL":"P1-TG", "TIME":"2005-03-27"}, {"REG":"SK", "RES":"PAN1", "WELL":"P1-TG", "TIME":"2005-04-13"}, {"REG":"SK", "RES":"PAN1", "WELL":"P1-TG", "TIME":"2006-06-07"}, {"REG":"SK", "RES":"PAN2", "WELL":"P2-TG", "TIME":"2009-01-18"}, {"REG":"SK", "RES":"PAN3", "WELL":"P3-TG", "TIME":"2009-03-01"}, {"REG":"SK", "RES":"PAN3", "WELL":"P3-TG", "TIME":"2010-03-14"}]'; foreach (json_decode($json, true) as $row) { $composite_key = implode('-', array_slice($row, 0, 3)); if (!isset($result[$composite_key])) { $row['TIME'] = [$row['TIME']]; $result[$composite_key] = $row; } else { $result[$composite_key]['TIME'][] = $row['TIME']; } } echo json_encode(array_values($result), JSON_PRETTY_PRINT);
Output for git.master, git.master_jit, rfc.property-hooks
[ { "REG": "SK", "RES": "PAN1", "WELL": "P1-TG", "TIME": [ "2005-03-27", "2005-04-13", "2006-06-07" ] }, { "REG": "SK", "RES": "PAN2", "WELL": "P2-TG", "TIME": [ "2009-01-18" ] }, { "REG": "SK", "RES": "PAN3", "WELL": "P3-TG", "TIME": [ "2009-03-01", "2010-03-14" ] } ]

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:
51.87 ms | 402 KiB | 8 Q