3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test_strings = [ '0<p>a</p>1<p>b</p>2<p>c</p>3', '0<p>a</p>1<p>b</p>2<p>c</p>', '<p>a</p>1<p>b</p>2<p>c</p>3', '<p>a</p>1<p>b</p>2<p>c</p>', '<p></p>1<p>b' ]; /** * Seperate a block of code by sub blocks. Example, removing all <script>...<script> tags from HTML kode * * @param string $str, text block * @param string $startDelimiter, string to match for start of block to be extracted * @param string $endDelimiter, string to match for ending the block to be extracted * @return array [all full blocks, whats left of string] */ function getDelimitedStrings($str, $startDelimiter, $endDelimiter) { $contents = array(); $startDelimiterLength = strlen($startDelimiter); $endDelimiterLength = strlen($endDelimiter); $startFrom = $contentStart = $contentEnd = $outStart = $outEnd = 0; while (false !== ($contentStart = strpos($str, $startDelimiter, $startFrom))) { $contentStart += $startDelimiterLength; $contentEnd = strpos($str, $endDelimiter, $contentStart); $outEnd = $contentStart - 1; if (false === $contentEnd) { break; } $contents['in'][] = substr($str, ($contentStart-$startDelimiterLength), ($contentEnd + ($startDelimiterLength*2) +1) - $contentStart); if( $outStart ){ $contents['out'][] = substr($str, ($outStart+$startDelimiterLength+1), $outEnd - $outStart - ($startDelimiterLength*2)); } else if( ($outEnd - $outStart - ($startDelimiterLength-1)) > 0 ){ $contents['out'][] = substr($str, $outStart, $outEnd - $outStart - ($startDelimiterLength-1)); } $startFrom = $contentEnd + $endDelimiterLength; $startFrom = $contentEnd; $outStart = $startFrom; } $total_length = strlen($str); $current_position = $outStart + $startDelimiterLength + 1; if( $current_position < $total_length ) $contents['out'][] = substr($str, $current_position); return $contents; } foreach($test_strings AS $string){ var_dump( getDelimitedStrings($string, '<p>', '</p>') ); }

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.80.0040.00819.36
8.3.70.0100.01316.58
8.3.60.0060.01218.56
8.3.50.0090.00717.34
8.3.40.0060.01318.67
8.3.30.0060.00918.57
8.3.20.0040.00420.85
8.3.10.0030.00620.90
8.3.00.0040.00421.55
8.2.200.0060.00318.88
8.2.190.0110.00418.41
8.2.180.0100.00725.92
8.2.170.0120.00322.96
8.2.160.0070.00720.22
8.2.150.0080.00025.66
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0090.00021.04
8.2.110.0060.00320.29
8.2.100.0090.00317.91
8.2.90.0060.00319.17
8.2.80.0030.00517.97
8.2.70.0000.00817.75
8.2.60.0040.00418.05
8.2.50.0060.00318.07
8.2.40.0000.00918.22
8.2.30.0000.00718.07
8.2.20.0040.00418.11
8.2.10.0030.00518.87
8.2.00.0050.00319.55
8.1.290.0000.01030.84
8.1.280.0150.00025.92
8.1.270.0000.01022.03
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0040.00722.03
8.1.230.0040.00720.93
8.1.220.0000.00817.78
8.1.210.0000.00818.77
8.1.200.0040.00417.22
8.1.190.0000.00817.11
8.1.180.0000.00818.10
8.1.170.0060.00318.43
8.1.160.0060.00318.86
8.1.150.0050.00218.80
8.1.140.0030.00618.86
8.1.130.0000.00717.42
8.1.120.0030.00317.36
8.1.110.0060.00317.48
8.1.100.0000.00717.46
8.1.90.0040.00717.42
8.1.80.0040.00417.42
8.1.70.0000.00717.47
8.1.60.0040.00417.60
8.1.50.0040.00417.43
8.1.40.0050.00317.35
8.1.30.0040.00417.61
8.1.20.0030.00617.59
8.1.10.0040.00417.43
8.1.00.0040.00417.50
8.0.300.0020.00518.77
8.0.290.0030.00616.63
8.0.280.0050.00318.45
8.0.270.0070.00016.82
8.0.260.0030.00316.82
8.0.250.0030.00616.98
8.0.240.0030.00316.88
8.0.230.0000.00816.98
8.0.220.0030.00316.89
8.0.210.0000.00716.77
8.0.200.0030.00516.93
8.0.190.0080.00316.85
8.0.180.0070.00016.91
8.0.170.0000.00816.82
8.0.160.0070.00016.88
8.0.150.0070.00016.84
8.0.140.0000.00816.75
8.0.130.0030.00313.32
8.0.120.0000.00816.75
8.0.110.0000.00716.82
8.0.100.0040.00416.94
8.0.90.0050.00216.93
8.0.80.0030.01016.78
8.0.70.0040.00416.71
8.0.60.0050.00216.89
8.0.50.0070.00016.96
8.0.30.0140.00917.11
8.0.20.0190.00317.16
8.0.10.0040.00416.96
8.0.00.0110.00916.75
7.4.330.0000.00515.55
7.4.320.0000.00616.43
7.4.300.0000.00616.61
7.4.290.0070.00016.62
7.4.280.0040.00416.63
7.4.270.0080.00416.46
7.4.260.0090.00016.64
7.4.250.0000.00816.46
7.4.240.0000.00816.64
7.4.230.0000.00716.63
7.4.220.0000.00916.61
7.4.210.0090.00916.56
7.4.200.0000.00716.69
7.4.160.0100.01016.53
7.4.140.0110.01117.86
7.4.130.0160.00316.48
7.4.120.0120.00816.37
7.4.110.0140.00616.45
7.4.100.0110.00916.62
7.4.90.0040.01616.45
7.4.80.0220.00319.39
7.4.70.0070.01516.53
7.4.60.0030.01516.56
7.4.50.0000.01416.48
7.4.40.0110.01116.37
7.4.00.0030.01114.98
7.3.330.0030.00313.41
7.3.320.0050.00013.39
7.3.310.0000.00716.25
7.3.300.0000.00716.38
7.3.290.0040.00416.25
7.3.280.0210.00016.35
7.3.260.0130.00916.60
7.3.240.0100.00916.45
7.3.230.0120.00616.48
7.3.210.0080.01116.44
7.3.200.0130.00316.65
7.3.190.0060.01216.66
7.3.180.0110.00616.29
7.3.170.0120.00616.43
7.3.160.0060.01416.35
7.3.70.0090.00514.84
7.3.60.0070.01014.42
7.3.50.0080.00814.85
7.3.40.0120.00814.60
7.3.30.0060.01114.67
7.3.20.0120.00914.76
7.3.10.0090.01214.75
7.3.00.0100.00914.72
7.2.330.0140.00716.38
7.2.320.0030.01516.95
7.2.310.0060.01516.73
7.2.300.0090.00916.73
7.2.290.0090.01016.59
7.2.200.0120.00615.04
7.2.190.0190.00015.21
7.2.180.0060.01115.04
7.2.170.0070.01015.02
7.2.160.0120.00514.87
7.2.150.0220.00015.11
7.2.140.0140.00815.04
7.2.130.0070.01115.01
7.2.120.0090.01114.98
7.2.110.0160.00815.05
7.2.100.0070.01415.09
7.2.90.0180.00314.94
7.2.80.0140.00915.20
7.2.70.0140.00315.18
7.2.60.0110.01014.93
7.2.50.0160.00614.90
7.2.40.0180.00415.23
7.2.30.0100.00815.11
7.2.20.0060.01214.98
7.2.10.0150.00515.09
7.2.00.0100.01115.20
7.1.300.0150.00813.82
7.1.290.0140.00613.91
7.1.280.0170.00514.09
7.1.270.0580.00413.88
7.1.260.0180.00913.87
7.1.250.0110.00613.90

preferences:
63.47 ms | 401 KiB | 5 Q