3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A1 { public function rows() { $a = array(); $a[] = array('parent_id' => 10, 'category_id' => 13, 'name' => 'id13'); $a[] = array('parent_id' => 8, 'category_id' => 12, 'name' => 'id12'); $a[] = array('parent_id' => 7, 'category_id' => 11, 'name' => 'id11'); $a[] = array('parent_id' => 7, 'category_id' => 10, 'name' => 'id10'); $a[] = array('parent_id' => 0, 'category_id' => 9, 'name' => 'id9'); $a[] = array('parent_id' => 0, 'category_id' => 8, 'name' => 'id8'); $a[] = array('parent_id' => 0, 'category_id' => 7, 'name' => 'id7'); return $a; } } $query = new A1; $categoryArray = array(); foreach($query->rows() as $row) { if(isset($categoryArray[$row['category_id']])) { $categoryArray[$row['parent_id']][$row['category_id']] = $categoryArray[$row['category_id']]; unset($categoryArray[$row['category_id']]); } else { $categoryArray[$row['parent_id']][$row['category_id']] = $row['name']; } } echo 'first stage <br>'; print_r($categoryArray); // second stage getLine($categoryArray()); function getLine($array){ foraech($array as $row){ if(is_array($row)) { echo('<ul>'); getLine($row); echo('</ul>'); } else { echo('<li>'.$row.'</li>'); } } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.240.0150.04312.40
5.4.230.0160.05012.39
5.4.220.0170.05212.39
5.4.210.0190.05212.39
5.4.200.0160.04912.39
5.4.190.0140.04712.39
5.4.180.0120.04912.39
5.4.170.0140.04612.40
5.4.160.0100.04612.39
5.4.150.0100.04312.39
5.4.140.0110.04312.08
5.4.130.0120.04012.06
5.4.120.0130.03912.03
5.4.110.0130.03912.03
5.4.100.0110.04712.02
5.4.90.0140.04412.03
5.4.80.0190.05612.03
5.4.70.0140.04112.02
5.4.60.0120.03812.02
5.4.50.0120.03912.02
5.4.40.0100.04212.01
5.4.30.0150.04212.01
5.4.20.0210.05312.00
5.4.10.0140.04412.00
5.4.00.0150.04611.50
5.3.280.0140.05012.71
5.3.270.0150.04612.72
5.3.260.0130.05012.72
5.3.250.0140.05012.72
5.3.240.0150.05312.72
5.3.230.0100.05512.71
5.3.220.0130.04412.68
5.3.210.0180.04912.68
5.3.200.0210.08012.68
5.3.190.0180.05712.68
5.3.180.0130.05712.67
5.3.170.0210.04912.67
5.3.160.0160.04912.67
5.3.150.0160.05712.67
5.3.140.0230.07112.66
5.3.130.0230.06912.65
5.3.120.0130.04812.66
5.3.110.0110.05212.65
5.3.100.0130.04712.12
5.3.90.0120.05012.10
5.3.80.0200.08012.09
5.3.70.0210.04512.09
5.3.60.0110.05012.07
5.3.50.0130.05112.02
5.3.40.0150.04712.02
5.3.30.0110.04911.98
5.3.20.0150.04311.76
5.3.10.0140.04511.72
5.3.00.0110.05011.71

preferences:
134.31 ms | 1398 KiB | 7 Q