3v4l.org

run code in 300+ PHP versions simultaneously
<?php $examples = [ 'The time is over. # its mean I\'m need to die.', 'Please help me. # Ghost. I am here alone.', 'Sorry. # help yourself.']; foreach ($examples as $example) { $exploded = explode('#', $example); $substr = trim(substr($exploded[1], 0, strpos($exploded[1], '.'))); var_dump($substr); } echo "------------------------\n"; //////////////////////////////////////////////////////////////////////////////////////////////////////////// $test = parseString('Sorry. # help yourself.'); function parseString($string) { $exploded = explode('#', $string); $substr = trim(substr($exploded[1], 0, strpos($exploded[1], '.'))); return $substr; } var_dump($test); echo "------------------------\n"; //////////////////////////////////////////////////////////////////////////////////////////////////////////// $stringExample = "The time is over. # its mean I'm need to die. Please help me. # Ghost. I am here alone. Sorry. # help yourself."; $test2 = parseString2($stringExample); function parseString2($string) { $result = []; $array = explode("\n", $string); foreach ($array as $a) { $exploded = explode('#', $a); $substr = trim(substr($exploded[1], 0, strpos($exploded[1], '.'))); $result[] = $substr; } return $result; } var_dump($test2); echo "------------------------\n"; //////////////////////////////////////////////////////////////////////////////////////////////////////////// $stringExample2 = "The time is over. # its mean I'm need to die. Please help me. # Ghost. I am here alone. Sorry. # help yourself."; var_dump(parseString3($stringExample2)); function parseString3($stringExample) { $result2 = []; $startBlock = false; $block = 0; foreach (str_split($stringExample) as $char) { if ($char === '#') { // Start block $startBlock = true; } else if ($startBlock && $char === '.') { // End block $result2[$block] = trim($result2[$block]); // Remove unnecessary whitespace $block++; $startBlock = false; } else if ($startBlock) { // Character to append to block if (!isset($result2[$block])) { $result2[$block] = ''; } $result2[$block] .= $char; } } return $result2; }

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.4.140.0140.00717.76
8.4.130.0080.00517.76
8.4.120.0130.00620.59
8.4.110.0070.00322.44
8.4.100.0110.00817.93
8.4.90.0100.01020.82
8.4.80.0130.00319.00
8.4.70.0110.00620.65
8.4.60.0100.01020.29
8.4.50.0050.00418.70
8.4.40.0100.01019.23
8.4.30.0100.01019.58
8.4.20.0060.01020.22
8.4.10.0050.00517.82
8.3.270.0140.00816.79
8.3.260.0120.00716.33
8.3.250.0130.00618.82
8.3.240.0170.00416.69
8.3.230.0020.00816.54
8.3.220.0050.00418.94
8.3.210.0120.00716.57
8.3.200.0040.00516.59
8.3.190.0130.00817.15
8.3.180.0110.00818.98
8.3.170.0070.01117.09
8.3.160.0090.00316.72
8.3.150.0090.01316.80
8.3.140.0090.00016.52
8.3.130.0060.00318.51
8.3.120.0100.00719.22
8.3.110.0030.00620.94
8.3.100.0000.01024.06
8.3.90.0110.00726.77
8.3.80.0060.00318.55
8.3.70.0070.00716.63
8.3.60.0080.00818.31
8.3.50.0120.00218.87
8.3.40.0080.00818.85
8.3.30.0070.00718.67
8.3.20.0000.00823.39
8.3.10.0040.00423.61
8.3.00.0050.00321.69
8.2.290.0110.00916.81
8.2.280.0100.01020.27
8.2.270.0080.00018.32
8.2.260.0040.00417.04
8.2.250.0040.00416.71
8.2.240.0150.00017.12
8.2.230.0040.00722.58
8.2.220.0090.00937.54
8.2.210.0070.01126.77
8.2.200.0040.00416.88
8.2.190.0100.01018.54
8.2.180.0120.00625.92
8.2.170.0060.00922.96
8.2.160.0070.01020.57
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00021.02
8.2.110.0080.00319.39
8.2.100.0030.00917.82
8.2.90.0060.00318.03
8.2.80.0050.00317.97
8.2.70.0030.00518.16
8.2.60.0050.00518.30
8.2.50.0080.00318.10
8.2.40.0050.00319.41
8.2.30.0030.00519.32
8.2.20.0000.00718.02
8.2.10.0040.00420.53
8.2.00.0040.00419.33
8.1.330.0110.00815.84
8.1.320.0150.00517.91
8.1.310.0100.00318.43
8.1.300.0070.01118.54
8.1.290.0030.00630.84
8.1.280.0070.00725.92
8.1.270.0060.00318.91
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00622.60
8.1.230.0120.00320.84
8.1.220.0050.00317.74
8.1.210.0000.00918.77
8.1.200.0050.00517.48
8.1.190.0040.00417.36
8.1.180.0030.00618.10
8.1.170.0050.00318.57
8.1.160.0000.00718.91
8.1.150.0050.00318.86
8.1.140.0070.00022.27
8.1.130.0030.00320.16
8.1.120.0000.00817.53
8.1.110.0000.00817.39
8.1.100.0000.00717.44
8.1.90.0030.00617.39
8.1.80.0050.00217.39
8.1.70.0060.00317.37
8.1.60.0030.00617.60
8.1.50.0060.00317.44
8.1.40.0030.00517.59
8.1.30.0060.00317.57
8.1.20.0080.00017.59
8.1.10.0030.00517.60
8.1.00.0000.00817.52
8.0.300.0040.00419.63
8.0.290.0050.00316.63
8.0.280.0000.00718.39
8.0.270.0040.00417.30
8.0.260.0030.00318.46
8.0.250.0030.00616.89
8.0.240.0040.00417.03
8.0.230.0000.00716.89
8.0.220.0000.00816.96
8.0.210.0030.00316.84
8.0.200.0030.00316.96
8.0.190.0060.00316.85
8.0.180.0050.00316.79
8.0.170.0030.00616.93
8.0.160.0000.00716.99
8.0.150.0000.00716.87
8.0.140.0030.00316.79
8.0.130.0000.00613.34
8.0.120.0000.00716.84
8.0.110.0040.00416.91
8.0.100.0040.00416.99
8.0.90.0080.00016.99
8.0.80.0100.00516.91
8.0.70.0000.00716.87
8.0.60.0050.00316.88
8.0.50.0000.00816.76
8.0.30.0050.01317.11
8.0.20.0100.01017.40
8.0.10.0000.00816.82
8.0.00.0150.00616.95
7.4.330.0050.00016.72
7.4.320.0030.00316.52
7.4.300.0000.00616.65
7.4.290.0080.00016.63
7.4.280.0000.00716.60
7.4.270.0000.00716.64
7.4.260.0070.00416.61
7.4.250.0040.00416.59
7.4.240.0070.00016.53
7.4.230.0070.00016.28
7.4.220.0080.00016.35
7.4.210.0110.00516.62
7.4.200.0000.00716.63
7.4.160.0050.01116.58
7.4.140.0110.00717.86
7.4.130.0100.01316.46
7.4.120.0090.00816.43
7.4.110.0180.00316.57
7.4.100.0160.00316.61
7.4.90.0070.01016.44
7.4.80.0070.01419.39
7.4.70.0110.00716.46
7.4.60.0060.00916.76
7.4.50.0130.00016.43
7.4.40.0100.00716.57
7.4.10.0090.00914.90
7.4.00.0080.01114.70
7.3.330.0000.00513.36
7.3.320.0030.00313.24
7.3.310.0070.00016.38
7.3.300.0030.00316.44
7.3.290.0040.00416.25
7.3.280.0040.01316.38
7.3.260.0140.00516.50
7.3.240.0090.01216.44
7.3.230.0130.00316.63
7.3.210.0100.00716.61
7.3.200.0070.01116.33
7.3.190.0130.00916.40
7.3.180.0070.01016.35
7.3.170.0090.01016.68
7.3.160.0060.00916.50
7.3.130.0100.01014.76
7.3.120.0030.01314.94
7.3.110.0090.00914.90
7.3.100.0070.00814.82
7.3.90.0040.01314.79
7.3.80.0090.00714.77
7.3.70.0060.00814.87
7.3.60.0050.00914.82
7.3.50.0070.00514.94
7.3.40.0080.00214.62
7.3.30.0030.00514.90
7.3.20.0060.00616.69
7.3.10.0050.00716.59
7.3.00.0140.00715.84
7.2.330.0090.01516.93
7.2.320.0100.00716.88
7.2.310.0030.01516.61
7.2.300.0070.01016.88
7.2.290.0100.01316.63
7.2.260.0130.00314.93
7.2.250.0060.01315.30
7.2.240.0100.00614.78
7.2.230.0060.01015.13
7.2.220.0080.00514.85
7.2.210.0050.00815.12
7.2.200.0050.00814.97
7.2.190.0090.00615.05
7.2.180.0020.01014.74
7.2.170.0070.00715.11
7.2.160.0020.01214.84
7.2.150.0030.00817.04
7.2.140.0060.00616.87
7.2.130.0140.01016.21
7.2.120.0150.00416.38
7.2.110.0150.00516.44
7.2.100.0190.00716.43
7.2.90.0140.01116.51
7.2.80.0290.01016.23
7.2.70.0110.00916.43
7.2.60.0110.00916.51
7.2.50.0150.00516.46
7.2.40.0140.00616.51
7.2.30.0090.01216.57
7.2.20.0100.00816.51
7.2.10.0140.00716.53
7.2.00.0090.01116.42
7.1.330.0050.01116.00
7.1.320.0050.01015.95
7.1.310.0050.00915.87
7.1.300.0050.01115.70
7.1.290.0060.00615.74
7.1.280.0030.01015.72
7.1.270.0100.00415.70
7.1.260.0070.00515.84
7.1.250.0100.00815.22
7.1.240.0090.00016.02
7.1.230.0040.01115.76
7.1.220.0030.01015.94
7.1.210.0030.00915.87
7.1.200.0030.01015.71
7.1.190.0060.00615.85
7.1.180.0000.01715.84
7.1.170.0090.00615.72
7.1.160.0070.01015.59
7.1.150.0000.01515.69
7.1.140.0060.00615.96
7.1.130.0070.00715.88
7.1.120.0070.00715.84
7.1.110.0070.00715.76
7.1.100.0090.00615.85
7.1.90.0040.01115.96
7.1.80.0090.00315.92
7.1.70.0140.00315.95
7.1.60.0000.01115.71
7.1.50.0030.01316.05
7.1.40.0030.00915.73
7.1.30.0070.00715.91
7.1.20.0030.01015.86
7.1.10.0000.01015.81
7.1.00.0090.00615.79
7.0.330.0260.00814.51
7.0.320.0030.00815.25
7.0.310.0030.01315.48
7.0.300.0090.00015.29
7.0.290.0100.00615.54
7.0.280.0000.01515.50
7.0.270.0040.00415.57
7.0.260.0100.00315.41
7.0.250.0130.00015.59
7.0.240.0080.00415.37
7.0.230.0090.00615.33
7.0.220.0130.00315.48
7.0.210.0000.01515.39
7.0.200.0080.00815.57
7.0.190.0070.00415.61
7.0.180.0130.00315.47
7.0.170.0030.01015.63
7.0.160.0040.01115.22
7.0.150.0030.00915.47
7.0.140.0030.01015.43
7.0.130.0030.01115.12
7.0.120.0070.00315.64
7.0.110.0030.00615.23
7.0.100.0030.01015.63
7.0.90.0030.01315.54
7.0.80.0080.00815.17
7.0.70.0000.00915.41
7.0.60.0000.01415.25
7.0.50.0000.00915.73
7.0.40.0040.00813.71
7.0.30.0000.01213.59
7.0.20.0000.01013.60
7.0.10.0050.00313.57
7.0.00.0080.00013.57
5.6.400.0000.01014.00
5.6.390.0090.00614.48
5.6.380.0100.00314.73
5.6.370.0040.00714.47
5.6.360.0030.01014.23
5.6.350.0070.01014.46
5.6.340.0040.00814.40
5.6.330.0000.01014.20
5.6.320.0090.00614.73
5.6.310.0000.00814.73
5.6.300.0100.00314.48
5.6.290.0120.00314.70
5.6.280.0040.00714.62
5.6.270.0030.00714.59
5.6.260.0120.00614.48
5.6.250.0100.00314.57
5.6.240.0030.00914.37
5.6.230.0070.00314.42
5.6.220.0030.00914.70
5.6.210.0090.00314.59
5.6.200.0030.00614.81
5.6.190.0080.00414.55
5.6.180.0060.00314.50
5.6.170.0080.00814.57
5.6.160.0000.01214.39
5.6.150.0030.01314.62
5.6.140.0090.00314.13
5.6.130.0070.00714.45
5.6.120.0040.00714.58
5.6.110.0080.00014.45
5.6.100.0120.00314.60
5.6.90.0040.00414.46
5.6.80.0060.00614.61
5.6.70.0060.00914.48
5.6.60.0070.00714.49
5.6.50.0040.01114.75
5.6.40.0060.00314.57
5.6.30.0030.00614.71
5.6.20.0030.00714.14
5.6.10.0080.00614.12
5.6.00.0000.01314.44

preferences:
36.04 ms | 403 KiB | 5 Q