3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getAllWholeWordPos($s,$word){ $b = " "; $delimited = "$b$word$b"; $retval = false; for ($i=0, $max = strlen( $s ); $i < $max; $i++) { if ( !ctype_alpha( $s[$i] ) ){ $s[$i] = $b; } } while ( ( $pos = stripos( $s, $delimited) ) !== false ) { $retval[] = $pos + 1; for ( $i=0, $max = $pos + 1 + strlen( $word ); $i <= $max; $i++) { $s[$i] = $b; } } return $retval; } $whole_word = "any"; $str = "Will *$whole_word* company do *$whole_word* job, (are there $whole_word)?"; echo "\nString: \"$str\""; $result = getAllWholeWordPos( $str, $whole_word ); $times = count( $result ); echo "\n\nThe word \"$whole_word\" occurs $times times:\n"; foreach ($result as $pos) { echo "\nPosition: ",$pos; }

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.120.0150.00420.69
8.3.110.0090.00020.94
8.3.100.0030.00624.06
8.3.90.0050.00326.77
8.3.80.0030.00618.56
8.3.70.0120.00318.58
8.3.60.0120.00616.88
8.3.50.0110.00516.70
8.3.40.0070.00718.85
8.3.30.0070.00718.93
8.3.20.0080.00021.89
8.3.10.0080.00021.80
8.3.00.0030.00619.79
8.2.240.0040.00417.27
8.2.230.0060.00322.58
8.2.220.0030.00637.54
8.2.210.0000.00826.77
8.2.200.0000.00816.75
8.2.190.0110.00718.66
8.2.180.0070.01018.41
8.2.170.0070.00722.96
8.2.160.0070.01120.48
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.04
8.2.110.0090.00022.26
8.2.100.0090.00319.48
8.2.90.0000.00819.18
8.2.80.0080.00017.97
8.2.70.0000.00817.75
8.2.60.0000.01018.03
8.2.50.0040.00418.07
8.2.40.0060.00318.16
8.2.30.0000.00818.14
8.2.20.0040.00418.03
8.2.10.0000.00718.20
8.2.00.0000.00718.10
8.1.300.0090.00018.26
8.1.290.0040.00730.84
8.1.280.0090.00925.92
8.1.270.0110.00424.66
8.1.260.0090.00026.35
8.1.250.0080.00028.09
8.1.240.0090.00020.86
8.1.230.0040.00717.83
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0000.00817.25
8.1.190.0030.00717.23
8.1.180.0000.00818.10
8.1.170.0040.00418.66
8.1.160.0000.00718.82
8.1.150.0070.00018.97
8.1.140.0000.00719.65
8.1.130.0000.00818.79
8.1.120.0070.00017.55
8.1.110.0040.00417.51
8.1.100.0080.00017.46
8.1.90.0030.00617.48
8.1.80.0040.00417.50
8.1.70.0030.00317.45
8.1.60.0000.01217.60
8.1.50.0070.00317.57
8.1.40.0000.00817.58
8.1.30.0040.00417.57
8.1.20.0000.00917.57
8.1.10.0040.00417.60
8.1.00.0000.00817.54
8.0.300.0000.00718.77
8.0.290.0040.00716.58
8.0.280.0030.00318.41
8.0.270.0040.00417.33
8.0.260.0040.00418.96
8.0.250.0000.00716.96
8.0.240.0040.00416.97
8.0.230.0050.00317.00
8.0.220.0040.00416.97
8.0.210.0050.00216.91
8.0.200.0030.00316.83
8.0.190.0060.00316.94
8.0.180.0070.00016.89
8.0.170.0050.00216.95
8.0.160.0040.00416.89
8.0.150.0000.00816.96
8.0.140.0000.01116.83
8.0.130.0000.00613.30
8.0.120.0000.00816.89
8.0.110.0040.00416.98
8.0.100.0050.00216.89
8.0.90.0040.00416.94
8.0.80.0130.00316.91
8.0.70.0000.00716.79
8.0.60.0000.00816.89
8.0.50.0040.00416.81
8.0.30.0110.00817.31
8.0.20.0110.00917.40
8.0.10.0040.00416.92
8.0.00.0030.01316.91
7.4.330.0000.00415.55
7.4.320.0060.00016.55
7.4.300.0030.00316.52
7.4.290.0000.00716.62
7.4.280.0000.00816.57
7.4.270.0000.00716.64
7.4.260.0030.00316.62
7.4.250.0000.00816.48
7.4.240.0070.00016.59
7.4.230.0030.00316.43
7.4.220.0100.01416.63
7.4.210.0070.01016.70
7.4.200.0040.00416.66
7.4.160.0120.00816.51
7.4.150.0090.01617.40
7.4.140.0130.00717.86
7.4.130.0060.01616.65
7.4.120.0110.00816.53
7.4.110.0130.00616.53
7.4.100.0150.00316.56
7.4.90.0100.00716.64
7.4.80.0030.02019.39
7.4.70.0120.00316.47
7.4.60.0170.00316.43
7.4.50.0100.00216.59
7.4.40.0090.00616.58
7.4.30.0000.01616.55
7.4.00.0050.01214.89
7.3.330.0000.00613.35
7.3.320.0000.00513.37
7.3.310.0000.00716.50
7.3.300.0000.00716.25
7.3.290.0080.00716.37
7.3.280.0080.00816.36
7.3.270.0160.00317.40
7.3.260.0130.00716.55
7.3.250.0140.00616.52
7.3.240.0100.00816.37
7.3.230.0130.01016.65
7.3.210.0060.01216.48
7.3.200.0080.00816.38
7.3.190.0090.00616.48
7.3.180.0030.01316.46
7.3.170.0110.01116.70
7.3.160.0070.01016.39
7.3.120.0090.00914.87
7.3.110.0030.01614.87
7.3.100.0120.00414.56
7.3.90.0000.01115.00
7.3.80.0090.00615.04
7.3.70.0030.00814.82
7.3.60.0030.01414.82
7.3.50.0030.01014.63
7.3.40.0040.00415.01
7.3.30.0060.00314.90
7.3.20.0120.00316.77
7.3.10.0110.00316.78
7.3.00.0040.00716.77
7.2.330.0110.00616.72
7.2.320.0050.01116.80
7.2.310.0070.01016.52
7.2.300.0060.01416.52
7.2.290.0070.01016.71
7.2.250.0090.01214.87
7.2.240.0030.01515.09
7.2.230.0060.00615.02
7.2.220.0090.00315.18
7.2.210.0000.01215.31
7.2.200.0060.00615.14
7.2.190.0100.00614.79
7.2.180.0060.00914.91
7.2.170.0070.00714.90
7.2.160.0070.00715.10
7.2.150.0080.00317.08
7.2.140.0090.00616.91
7.2.130.0060.00616.77
7.2.120.0070.00317.02
7.2.110.0040.01116.93
7.2.100.0130.00316.91
7.2.90.0060.00916.81
7.2.80.0070.00416.76
7.2.70.0110.00017.07
7.2.60.0030.01016.82
7.2.50.0040.01116.95
7.2.40.0060.00316.97
7.2.30.0000.01317.12
7.2.20.0040.00816.79
7.2.10.0060.01017.04
7.2.00.0090.00616.98
7.1.330.0060.00615.96
7.1.320.0040.00415.84
7.1.310.0080.00315.80
7.1.300.0090.00315.78
7.1.290.0040.00815.83
7.1.280.0060.00915.91
7.1.270.0000.01415.59
7.1.260.0060.00615.84
7.1.250.0030.01015.96
7.1.240.0040.00815.75
7.1.230.0030.01315.81
7.1.220.0060.00615.77
7.1.210.0070.00315.84
7.1.200.0050.00915.87
7.1.190.0000.00915.89
7.1.180.0000.00915.77
7.1.170.0040.00715.91
7.1.160.0070.01015.85
7.1.150.0100.00315.84
7.1.140.0000.01115.94
7.1.130.0030.00915.86
7.1.120.0000.01615.72
7.1.110.0040.00415.84
7.1.100.0060.00615.71
7.1.90.0080.00315.49
7.1.80.0050.00515.91
7.1.70.0060.00816.47
7.1.60.0160.00525.54
7.1.50.0080.01425.31
7.1.40.0120.01025.01
7.1.30.0070.01525.09
7.1.20.0080.01425.21
7.1.10.0030.00816.12
7.1.00.0050.01116.18
7.0.330.0000.00915.45
7.0.320.0030.01015.22
7.0.310.0060.00915.21
7.0.300.0040.00715.39
7.0.290.0090.00015.16
7.0.280.0100.00015.58
7.0.270.0080.00415.39
7.0.260.0050.00515.45
7.0.250.0140.00015.45
7.0.240.0030.00615.30
7.0.230.0090.00315.45
7.0.220.0060.00915.61
7.0.210.0080.00415.57
7.0.200.0060.00515.95
7.0.190.0050.00915.99
7.0.180.0020.01115.97
7.0.170.0030.01015.88
7.0.160.0070.00715.89
7.0.150.0040.01015.70
7.0.140.0060.00615.79
7.0.130.0000.01016.01
7.0.120.0400.00516.01
7.0.110.0030.00915.84
7.0.100.0020.01315.87
7.0.90.0020.01315.86
7.0.80.0060.01115.76
7.0.70.0050.01115.78
7.0.60.0020.01315.85
7.0.50.0050.00516.01
7.0.40.0060.00715.14
7.0.30.0080.00315.05
7.0.20.0030.01214.93
7.0.10.0050.00914.96
7.0.00.0100.00514.95
5.6.400.0120.00314.67
5.6.390.0000.01814.43
5.6.380.0080.00414.58
5.6.370.0040.00414.19
5.6.360.0060.00614.08
5.6.350.0060.00614.41
5.6.340.0000.00914.09
5.6.330.0060.00814.27
5.6.320.0030.01014.04
5.6.310.0030.00714.10
5.6.300.0000.01414.46
5.6.290.0060.01314.66
5.6.280.0000.01414.39
5.6.270.0070.00714.76
5.6.260.0100.00314.71
5.6.250.0070.01014.65
5.6.240.0060.01014.40
5.6.230.0070.00714.42
5.6.220.0070.00714.38
5.6.210.0000.01214.35
5.6.200.0110.00414.39
5.6.190.0100.00714.33
5.6.180.0030.01014.54
5.6.170.0040.01214.37
5.6.160.0040.01114.37
5.6.150.0030.00614.34
5.6.140.0070.00714.30
5.6.130.0040.01114.89
5.6.120.0090.00614.39
5.6.110.0110.00414.66
5.6.100.0060.00914.55
5.6.90.0090.00614.48
5.6.80.0060.00914.26
5.6.70.0070.00714.54
5.6.60.0070.00714.34
5.6.50.0070.00414.37
5.6.40.0060.00614.29
5.6.30.0070.01014.51
5.6.20.0030.00814.41
5.6.10.0030.01014.24
5.6.00.0030.00914.39

preferences:
28.62 ms | 403 KiB | 5 Q