3v4l.org

run code in 300+ PHP versions simultaneously
<?phpfunction strposGetContext($haystack, $needle, $context = 10, $ignoreChars = "-\n /") { $ignore = str_split($ignoreChars); $needle = str_replace($ignore, '', $needle); $cleanedHaystack = str_replace($ignore, '', $haystack); $position = 0; $results = []; while (($foundStart = stripos($cleanedHaystack, $needle, $position)) !== false) { $foundEnd = $foundStart + strlen($needle); $position = $foundEnd; $dirtyHaystackPosition = 0; while ($dirtyHaystackPosition < $foundEnd && $dirtyHaystackPosition < strlen($haystack)) { if (in_array($haystack[$dirtyHaystackPosition], $ignore)) { if ($dirtyHaystackPosition <= $foundStart) { $foundStart++; } $foundEnd++; } $dirtyHaystackPosition++; } $results[] = substr( $haystack, $foundStart - $context < 0 ? 0 : $foundStart - $context, $found_end - $found_start + $context ); } return $results;}$text = 'This is some text target-text and we have some string target text you are looking for!!!! target----text WOO';var_dump(strposGetContext($text, 'targettext'));

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.0070.00716.58
8.3.60.0070.01418.55
8.3.50.0080.00922.70
8.3.40.0170.00018.59
8.3.30.0030.01018.79
8.3.20.0040.00420.27
8.3.10.0080.00023.65
8.3.00.0040.00417.38
8.2.180.0070.01316.32
8.2.170.0120.00622.96
8.2.160.0100.00320.40
8.2.150.0110.00024.18
8.2.140.0060.00324.66
8.2.130.0120.00626.16
8.2.120.0080.00020.90
8.2.110.0000.00922.25
8.2.100.0040.00719.51
8.2.90.0080.00019.23
8.2.80.0000.00817.97
8.2.70.0000.00817.50
8.2.60.0050.00518.04
8.2.50.0040.00418.07
8.2.40.0030.00518.22
8.2.30.0000.00817.81
8.2.20.0030.00517.54
8.2.10.0030.00517.91
8.2.00.0000.00717.59
8.1.280.0080.00625.92
8.1.270.0090.00023.82
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00023.84
8.1.230.0030.01219.16
8.1.220.0000.00717.74
8.1.210.0030.00618.77
8.1.200.0060.00317.00
8.1.190.0040.00417.10
8.1.180.0040.00418.10
8.1.170.0030.00618.52
8.1.160.0000.00722.01
8.1.150.0070.00018.66
8.1.140.0000.00717.21
8.1.130.0000.00817.71
8.1.120.0040.00417.32
8.1.110.0030.00517.14
8.1.100.0040.00417.19
8.1.90.0030.00317.28
8.1.80.0040.00417.23
8.1.70.0000.00717.19
8.1.60.0040.00417.35
8.1.50.0030.00517.38
8.1.40.0040.00417.35
8.1.30.0040.00417.39
8.1.20.0000.00717.38
8.1.10.0000.00817.44
8.1.00.0030.00717.36
8.0.300.0050.00318.77
8.0.290.0070.00016.58
8.0.280.0070.00018.24
8.0.270.0000.00817.17
8.0.260.0030.00317.23
8.0.250.0000.00716.70
8.0.240.0000.00716.86
8.0.230.0030.00316.70
8.0.220.0030.00316.77
8.0.210.0000.00716.79
8.0.200.0030.00316.85
8.0.190.0040.00416.80
8.0.180.0090.00016.67
8.0.170.0000.00816.72
8.0.160.0000.00716.81
8.0.150.0070.00016.70
8.0.140.0000.00716.65
8.0.130.0040.00413.30
8.0.120.0000.00816.71
8.0.110.0030.00516.70
8.0.100.0020.00516.66
8.0.90.0040.00416.77
8.0.80.0120.00316.70
8.0.70.0040.00416.58
8.0.60.0000.00816.74
8.0.50.0000.00716.56
8.0.30.0120.00717.08
8.0.20.0140.00817.40
8.0.10.0040.00416.73
8.0.00.0050.01316.45
7.4.330.0050.00015.12
7.4.320.0000.00616.46
7.4.300.0000.00616.25
7.4.290.0040.00416.37
7.4.280.0040.00416.35
7.4.270.0070.00016.45
7.4.260.0000.00716.41
7.4.250.0040.00316.46
7.4.240.0030.00416.42
7.4.230.0050.00316.11
7.4.220.0110.00716.52
7.4.210.0000.01716.47
7.4.200.0000.00716.48
7.4.160.0060.00916.51
7.4.150.0120.00417.40
7.4.140.0130.00817.86
7.4.130.0120.00416.42
7.4.120.0070.01016.39
7.4.110.0060.01016.46
7.4.100.0100.00716.41
7.4.90.0040.01216.38
7.4.80.0140.00719.39
7.4.70.0030.01316.40
7.4.60.0030.01316.26
7.4.50.0000.00816.48
7.4.40.0060.00916.47
7.4.30.0040.01616.31
7.3.330.0050.00013.23
7.3.320.0020.00212.99
7.3.310.0000.00715.96
7.3.300.0030.00316.15
7.3.290.0060.01416.16
7.3.280.0020.01216.08
7.3.270.0060.01317.40
7.3.260.0100.01016.22
7.3.250.0070.01016.18
7.3.240.0030.01316.16
7.3.230.0100.00716.48
7.3.210.0120.00616.33
7.3.200.0090.00919.39
7.3.190.0030.01316.17
7.3.180.0130.00316.23
7.3.170.0070.01316.27
7.3.160.0060.00916.37
7.2.330.0100.01216.30
7.2.320.0070.01516.33
7.2.310.0060.00916.57
7.2.300.0270.01216.35
7.2.290.0100.01116.29
5.4.320.0050.03812.45
5.4.310.0090.03512.45
5.4.300.0080.04212.45
5.4.290.0070.03912.45
5.4.280.0100.03412.34
5.4.270.0070.03612.34
5.4.260.0070.04012.35
5.4.250.0090.03812.35
5.4.240.0050.03612.35
5.4.230.0060.03712.34
5.4.220.0070.03612.34
5.4.210.0070.03712.34
5.4.200.0030.04112.34
5.4.190.0060.03812.34
5.4.180.0050.03812.33
5.4.170.0050.03612.34
5.4.160.0060.03412.34
5.4.150.0040.03612.34
5.4.140.0070.03612.02
5.4.130.0070.03612.01
5.4.120.0080.03511.96
5.4.110.0080.03411.96
5.4.100.0070.03711.96
5.4.90.0070.03711.96
5.4.80.0040.03911.96
5.4.70.0080.03311.96
5.4.60.0070.03511.96
5.4.50.0050.03911.96
5.4.40.0080.03511.95
5.4.30.0070.03411.95
5.4.20.0050.03511.95
5.4.10.0070.03311.95
5.4.00.0060.03511.44

preferences:
40.86 ms | 401 KiB | 5 Q