3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sql = array(array('id' => 0, 'nom' => 'A', 'temp' => 1.1, 'autre' => 0), array('id' => 1, 'nom' => 'A', 'temp' => 2.1, 'autre' => 10), array('id' => 2, 'nom' => 'A', 'temp' => 3.1, 'autre' => 20), array('id' => 3, 'nom' => 'B', 'temp' => 4.1, 'autre' => 30), array('id' => 4, 'nom' => 'C', 'temp' => 5.1, 'autre' => 40), array('id' => 5, 'nom' => 'B', 'temp' => 6.1, 'autre' => 50), array('id' => 6, 'nom' => 'A', 'temp' => 7.1, 'autre' => 60)); $final = array(); foreach ($sql as $s) if(!in_array($s['nom'], $final)) { array_merge($final[$s['nom']]['data'], array()); array_push($final[$s['nom']]['data'], $s['temp']); } else array_push($final[$s['nom']]['data'], $s['temp']); print_r($final);
Output for git.master, git.master_jit
Warning: Undefined array key "A" in /in/TZWDq on line 12 Warning: Trying to access array offset on value of type null in /in/TZWDq on line 12 Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /in/TZWDq:12 Stack trace: #0 /in/TZWDq(12): array_merge(NULL, Array) #1 {main} thrown in /in/TZWDq on line 12
Process exited with code 255.
Output for rfc.property-hooks
Warning: Undefined array key "A" in /in/TZWDq on line 12 Warning: Trying to access array offset on null in /in/TZWDq on line 12 Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /in/TZWDq:12 Stack trace: #0 /in/TZWDq(12): array_merge(NULL, Array) #1 {main} thrown in /in/TZWDq on line 12
Process exited with code 255.

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.72 ms | 401 KiB | 8 Q