3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( 0 => array('id' => 8, 'month' => 1, 'cost' => 12500), 1 => array('id' => 8, 'month' => 2, 'cost' => 14200), 2 => array('id' => 9, 'month' => 1, 'cost' => 23000), 3 => array('id' => 9, 'month' => 2, 'cost' => 18000), ); $by_id = []; foreach($data as $x) { $by_id[$x['id']][$x['month']] = $x['cost']; // e.g. $by_id[8][2] = 14200; } $html = []; $html[] = '<table>'; $html[] = '<tr><th>ID</th><th>Jan</th><th>Feb</th></tr>'; foreach($by_id as $id => $months) { $html[] = '<tr>'; $html[] = "<td>{$id}</td>"; foreach($months as $month => $cost) { $html[] = "<td>{$cost}</td>"; } $html[] = '</tr>'; } $html[] = '</table>'; echo implode("\n", $html);
Output for git.master, git.master_jit, rfc.property-hooks
<table> <tr><th>ID</th><th>Jan</th><th>Feb</th></tr> <tr> <td>8</td> <td>12500</td> <td>14200</td> </tr> <tr> <td>9</td> <td>23000</td> <td>18000</td> </tr> </table>

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:
94.79 ms | 1272 KiB | 4 Q