3v4l.org

run code in 500+ PHP versions simultaneously
<?php function showCell($cell, $isHeader, $selectedTitle) { echo '<td>'; if ($selectedTitle || $isHeader) { echo htmlspecialchars($cell); } else { echo sprintf('<a href="?title=%1$s">%1$s</a>', htmlspecialchars($cell)); } echo '</td>', PHP_EOL; } function showRow($cellsToShow, $isHeader, $selectedTitle) { if ($isHeader) { echo '<thead>', PHP_EOL; } echo '<tr>', PHP_EOL; foreach ($cellsToShow as $cell) { showCell($cell, $isHeader, $selectedTitle); } echo '</tr>', PHP_EOL; if ($isHeader) { echo '</thead>', PHP_EOL; } } function showTable($handle, $selectedTitle) { $idx = 0; echo '<table>', PHP_EOL; while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { // If we're on the first row which holds titles, always show. // Also, if the user selected a title, and it matches this row's title, show it. if(0 !== $idx && $selectedTitle && $row[0] !== $selectedTitle){ continue; } // cellsToShow is always an array. If we're showing based on a selection, it is everything. // Otherwise, it will be an array of just the first cell. This last seems weird, but it // allows the showRow method to not concern itself with higher level logic. $cellsToShow = $selectedTitle ? $row : [$row[0]]; showRow($cellsToShow, $idx++ === 0, $selectedTitle); } echo '</table>', PHP_EOL; } // Mock a CSV file in memory for demo purposes $handle = fopen('php://memory', 'rb+'); fwrite($handle, "Title,Author,Year\nBook 1,Alice,2020\nBook 2,Bob,2019\nBook 3,Charlie,1980"); rewind($handle); // Grab the title from the query string, default to null if not found $selectedTitle = $_GET['title'] ?? null; showTable($handle, $selectedTitle); fclose($handle);

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)
8.5.60.0110.00716.91
8.5.50.0080.00116.69
8.5.30.0140.00919.66
8.5.20.0120.00719.58
8.5.10.0130.00520.09
8.5.00.0130.00820.15
8.4.210.0120.00919.71
8.4.180.0090.01125.73
8.4.170.0130.00823.94
8.4.160.0130.00823.68
8.4.150.0080.00516.91
8.4.140.0140.00717.87
8.4.130.0120.00917.71
8.4.120.0110.00922.31
8.4.110.0150.00620.36
8.4.100.0100.01118.52
8.4.90.0110.00819.19
8.4.80.0070.01320.39
8.4.70.0130.00618.19
8.4.60.0120.01119.18
8.4.50.0110.00817.92
8.4.40.0160.00319.54
8.4.30.0130.00720.67
8.4.20.0030.00622.32
8.4.10.0100.00023.97
8.3.300.0100.01020.59
8.3.290.0100.01120.85
8.3.280.0130.00718.49
8.3.270.0110.01016.51
8.3.260.0030.00516.75
8.3.250.0140.00518.93
8.3.240.0050.00316.92
8.3.230.0130.00716.63
8.3.220.0130.00618.88
8.3.210.0150.00416.92
8.3.200.0050.00416.76
8.3.190.0100.00817.37
8.3.180.0070.00316.86
8.3.170.0070.01118.94
8.3.160.0100.01016.81
8.3.150.0090.00919.16
8.3.140.0110.00317.04
8.3.130.0080.00818.39
8.3.120.0030.00919.00
8.3.110.0060.00316.63
8.3.100.0030.00716.56
8.3.90.0040.00426.77
8.3.80.0060.00316.63
8.3.70.0040.01116.75
8.3.60.0130.00318.56
8.3.50.0090.01218.37
8.3.40.0150.00020.04
8.3.30.0140.00018.51
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.300.0120.00918.09
8.2.290.0110.00720.43
8.2.280.0140.00718.40
8.2.270.0090.00916.79
8.2.260.0080.00016.79
8.2.250.0060.00918.44
8.2.240.0040.00418.93
8.2.230.0040.00420.94
8.2.220.0040.00424.06
8.2.210.0040.00426.77
8.2.200.0060.00318.18
8.2.190.0090.01218.41
8.2.180.0070.00725.92
8.2.170.0120.00318.88
8.2.160.0110.00422.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00226.16
8.2.110.0060.00319.51
8.2.100.0110.00317.84
8.2.90.0040.00417.88
8.2.80.0040.00418.78
8.2.70.0080.00017.38
8.2.60.0040.00417.50
8.2.50.0070.00819.45
8.2.40.0050.00920.06
8.2.30.0040.01019.06
8.2.20.0090.00419.89
8.2.10.0090.00519.08
8.2.00.0070.00719.42
8.1.340.0120.00819.89
8.1.330.0110.01121.96
8.1.320.0150.00416.10
8.1.310.0080.00018.45
8.1.300.0030.00516.73
8.1.290.0090.00030.84
8.1.280.0160.00025.92
8.1.270.0080.00824.66
8.1.260.0090.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00319.28
8.1.230.0050.00517.71
8.1.220.0000.00917.78
8.1.210.0030.00618.77
8.1.200.0080.00017.35
8.1.190.0000.00817.22
8.1.180.0070.00719.04
8.1.170.0070.00819.21
8.1.160.0110.00319.33
8.1.150.0130.00219.24
8.1.140.0120.00218.85
8.1.130.0140.00319.20
8.1.120.0120.00519.26
8.1.110.0110.00619.25
8.1.100.0140.00219.25
8.1.90.0130.00419.22
8.1.80.0130.00319.21
8.1.70.0150.00119.25
8.1.60.0160.00319.25
8.1.50.0070.01119.23
8.1.40.0160.00319.28
8.1.30.0150.00519.25
8.1.20.0140.00419.25
8.1.10.0110.00719.26
8.1.00.0130.00619.20
8.0.300.0030.00318.80
8.0.290.0000.00716.75
8.0.280.0090.00419.20
8.0.270.0080.00518.76
8.0.260.0120.00418.99
8.0.250.0130.00419.00
8.0.240.0080.00819.04
8.0.230.0120.00419.05
8.0.220.0120.00519.02
8.0.210.0100.00619.02
8.0.200.0110.00619.05
8.0.190.0110.00519.00
8.0.180.0130.00419.05
8.0.170.0130.00319.04
8.0.160.0080.00819.08
8.0.150.0120.00419.02
8.0.140.0120.00519.02
8.0.130.0110.00618.99
8.0.120.0130.00319.04
8.0.110.0090.00619.04
8.0.100.0070.00919.04
8.0.90.0130.00319.04
8.0.80.0120.00519.06
8.0.70.0120.00418.98
8.0.60.0120.00418.99
8.0.50.0110.00518.98
8.0.30.0130.00319.03
8.0.20.0110.00619.02
8.0.10.0110.00519.00

preferences:
58.3 ms | 1158 KiB | 5 Q