3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = json_decode('[ { "nsr": "000086310", "type": "3", "date": "2015-07-18", "time": "00:06", "pis": "12138790985" }, { "nsr": "000086313", "type": "3", "date": "2015-07-18", "time": "00:33", "pis": "16073736879" }, { "nsr": "000086316", "type": "3", "date": "2015-07-18", "time": "00:58", "pis": "16634402451" }, { "nsr": "000086316", "type": "3", "date": "2015-07-19", "time": "00:58", "pis": "98127981729" }, { "nsr": "000086316", "type": "3", "date": "2015-07-19", "time": "00:58", "pis": "12398712938" } ]', true); $result = []; foreach ($array as ['date' => $d, 'pis' => $p]) { if (!isset($ref[$d])) { $ref[$d] = ['date' => $d]; $result[] =& $ref[$d]; } $ref[$d]['pis'][] = $p; } var_export($result);
Output for git.master_jit, git.master
array ( 0 => array ( 'date' => '2015-07-18', 'pis' => array ( 0 => '12138790985', 1 => '16073736879', 2 => '16634402451', ), ), 1 => array ( 'date' => '2015-07-19', 'pis' => array ( 0 => '98127981729', 1 => '12398712938', ), ), )

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