3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = <<<EOT { "data": [ { "product_id": "123456", "item": "ZAD", "time": "15:30", "quantity": 1 }, { "product_id": "24534", "item": "REST", "time": "5:30", "quantity": 1 }, { "product_id": "123456", "item": "RAD", "time": "10:30", "quantity": 2 } ] } EOT; $d_data = json_decode($json, true); $f_data = $d_data['data']; $result = []; foreach($f_data as $data) { $result[$data['product_id']][$data['item']] = [ $data['time'], $data['quantity'] ]; } print_r($result);
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [123456] => Array ( [ZAD] => Array ( [0] => 15:30 [1] => 1 ) [RAD] => Array ( [0] => 10:30 [1] => 2 ) ) [24534] => Array ( [REST] => Array ( [0] => 5:30 [1] => 1 ) ) )

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:
45.49 ms | 1332 KiB | 4 Q