3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = <<<STR Maths Maths|Algebre Maths|Algebre|Algebre 1 Maths|Algebre|Algebre 2 Maths|Algebre|Algebre 3 Maths|Analyse Maths|Analyse|Analyse 1 Maths|Analyse|Analyse 2 Maths|Probabilité physics STR; function cleanupLines(array $lines): array { foreach ($lines as $index => $line) { if ($index > 0 && strpos($line, $lines[$index - 1]) === 0) { unset($lines[$index - 1]); } } return $lines; } function lineToArray(array $lineParts): array { if (count($lineParts) > 1) { return [$lineParts[0] => lineToArray(array_slice($lineParts, 1))]; } return $lineParts; } $lines = preg_split('/\r?\n/', $input); $lines = cleanupLines($lines); $result = array_reduce($lines, static function (array $result, string $line): array { $lineParts = explode('|', $line); $arrayPart = lineToArray($lineParts); return array_merge_recursive($result, $arrayPart); }, []); print_r($result);

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.3.70.0120.00318.34
8.3.60.0090.00618.56
8.3.50.0030.01418.23
8.3.40.0040.01120.33
8.3.30.0060.01018.96
8.3.20.0050.00320.91
8.3.10.0080.00020.51
8.3.00.0040.00422.58
8.2.190.0110.00717.00
8.2.180.0140.00016.63
8.2.170.0070.00722.96
8.2.160.0060.00819.54
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00026.16
8.2.110.0100.01322.14
8.2.100.0150.00318.08
8.2.90.0060.00617.63
8.2.80.0060.00318.88
8.2.70.0080.00017.88
8.2.60.0030.00618.16
8.2.50.0000.00818.05
8.2.40.0000.00818.22
8.2.30.0050.00319.55
8.2.20.0000.00718.18
8.2.10.0070.00019.39
8.2.00.0040.00419.54
8.1.280.0110.01125.92
8.1.270.0040.00420.68
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0190.00320.84
8.1.230.0090.00317.72
8.1.220.0050.00517.74
8.1.210.0000.00818.77
8.1.200.0060.00317.61
8.1.190.0030.00517.35
8.1.180.0130.00418.10
8.1.170.0040.00417.62
8.1.160.0000.01018.88
8.1.150.0000.00718.86
8.1.140.0000.00718.93
8.1.130.0050.00319.14
8.1.120.0020.00517.54
8.1.110.0080.00017.53
8.1.100.0030.00517.52
8.1.90.0040.00417.59
8.1.80.0000.00917.55
8.1.70.0040.00417.63
8.1.60.0040.00417.79
8.1.50.0080.00017.70
8.1.40.0040.00417.69
8.1.30.0090.00017.75
8.1.20.0040.00417.66
8.1.10.0000.00817.65
8.1.00.0000.00917.67
8.0.300.0040.00420.69
8.0.290.0050.00317.13
8.0.280.0070.00018.49
8.0.270.0040.00418.15
8.0.260.0000.00718.54
8.0.250.0000.00817.13
8.0.240.0000.00717.09
8.0.230.0070.00017.17
8.0.220.0040.00417.11
8.0.210.0040.00417.15
8.0.200.0000.00817.22
8.0.190.0000.00717.19
8.0.180.0040.00417.07
8.0.170.0000.00917.16
8.0.160.0090.00017.14
8.0.150.0030.00317.14
8.0.140.0000.00917.10
8.0.130.0000.00613.46
8.0.120.0030.00617.16
8.0.110.0070.00017.23
8.0.100.0040.00417.13
8.0.90.0060.00317.12
8.0.80.0090.00917.09
8.0.70.0020.00516.99
8.0.60.0050.00216.91
8.0.50.0030.00517.13
8.0.30.0110.00717.33
8.0.20.0100.00917.35
8.0.10.0070.00017.16
8.0.00.0000.01817.07
7.4.330.0030.00315.55
7.4.320.0000.00716.85
7.4.300.0030.00516.80
7.4.290.0050.00216.72
7.4.280.0000.00716.58
7.4.270.0030.00316.81
7.4.260.0000.00513.50
7.4.250.0040.00416.83
7.4.240.0000.00716.77
7.4.230.0030.00316.74
7.4.220.0000.00716.86
7.4.210.0070.00916.81
7.4.200.0030.00316.65
7.4.130.0080.01116.80
7.4.120.0170.00716.94
7.4.110.0170.00016.71
7.4.100.0090.00916.55
7.4.90.0050.01116.63
7.4.80.0090.00919.39
7.4.70.0000.01516.81
7.4.60.0080.00816.74
7.4.50.0060.00916.83
7.4.40.0150.00916.53
7.4.30.0090.00616.52
7.4.20.0070.01016.48
7.4.10.0080.00816.73
7.4.00.0130.00716.63
7.3.330.0030.00316.46
7.3.320.0060.00013.55
7.3.310.0030.00316.55
7.3.300.0000.00716.54
7.3.290.0120.00616.54
7.3.260.0100.00716.78
7.3.240.0070.01216.66
7.3.230.0090.01216.83
7.3.210.0210.00416.59
7.3.200.0030.01416.60
7.3.190.0050.01816.71
7.3.180.0160.00016.59
7.3.170.0060.01216.67
7.3.160.0170.00616.81
7.3.150.0180.00016.55
7.3.140.0100.00716.79
7.3.130.0070.01016.77
7.3.120.0080.01316.73
7.3.110.0060.01116.65
7.3.100.0060.00916.78
7.3.90.0040.01216.69
7.3.80.0090.00616.54
7.3.70.0110.00616.48
7.3.60.0100.01316.43
7.3.50.0100.00616.57
7.3.40.0110.00716.61
7.3.30.0090.01516.66
7.3.20.0050.01116.61
7.3.10.0100.01316.69
7.3.00.0080.00816.49
7.2.330.0150.00316.80
7.2.320.0120.00617.03
7.2.310.0130.00316.84
7.2.300.0030.01516.93
7.2.290.0130.01016.68
7.2.280.0190.00316.71
7.2.270.0090.01116.85
7.2.260.0040.02016.80
7.2.250.0120.00616.88
7.2.240.0090.00616.89
7.2.230.0100.00716.84
7.2.220.0080.00816.75
7.2.210.0110.00916.59
7.2.200.0120.00616.64
7.2.190.0140.00716.81
7.2.180.0110.00716.78
7.2.170.0040.01416.89
7.2.160.0090.01316.94
7.2.150.0090.01017.04
7.2.140.0130.00916.96
7.2.130.0070.01816.84
7.2.120.0060.01416.91
7.2.110.0030.01516.85
7.2.100.0110.00817.00
7.2.90.0130.00616.70
7.2.80.0030.01516.76
7.2.70.0110.00716.79
7.2.60.0070.01716.81
7.2.50.0090.01216.84
7.2.40.0090.00816.96
7.2.30.0070.01016.99
7.2.20.0100.01016.84
7.2.10.0100.01116.88
7.2.00.0090.00916.87

preferences:
49.18 ms | 401 KiB | 5 Q