3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'I try both of previous answer (not working for me 😥). After downloading the last beta, not working too. After I changed the iOS Deployement target (11.1 -> 14.0) it\'s working Hope that can help someone 🙏🏽'; $bl = [ 'thank you', 'thanks', 'thankyou', 'best regards', 'regards', 'cheers', 'thx', 'thanx', 'appreciated', 'good afternoon', 'buenas tardes', 'hi there', 'good day', 'This is long 😊', 'good morning', 'hope that can help', 'help someone', ]; function regex(array $bl, string $string) { $m = []; foreach ($bl as $word) { preg_match_all('#'.$word.'#i', $string, $matches, PREG_SET_ORDER, 0); foreach ($matches as $e) { $m[] = $e[0]; } } } function str(array $bl, string $string) { $m = []; foreach ($bl as $word) { if (stripos($string, $word) !== false) { $m[] = $word; } } } // bench $time = microtime(true); $i = 10000; while ($i--) { str($bl, $str); } echo 'stripos: '.round(microtime(true) - $time, 3)."\n"; $time = microtime(true); $i = 10000; while ($i--) { regex($bl, $str); } echo 'Regex: '.round(microtime(true) - $time, 3)."\n";

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)
7.4.120.0100.13516.52
7.4.110.0160.13916.86
7.4.100.0100.14216.99
7.4.90.0030.14516.70
7.4.80.0100.15716.95
7.4.70.0070.15216.81
7.4.60.0100.19516.82
7.4.50.0100.19716.52
7.4.40.0130.12616.68
7.4.30.0160.19816.61
7.4.20.0160.13816.75
7.4.10.0160.11816.89
7.4.00.0100.12616.67
7.3.240.0100.13316.86
7.3.230.0060.12616.51
7.3.220.0160.13616.58
7.3.210.0130.12816.92
7.3.200.0100.12116.59
7.3.190.0130.11516.56
7.3.180.0190.11716.59
7.3.170.0070.12416.59
7.3.160.0130.14216.81
7.3.150.0140.12716.49
7.3.140.0130.12616.61
7.3.130.0060.14016.53
7.3.120.0130.15216.63
7.3.110.0130.13816.78
7.3.100.0130.12016.92
7.3.90.0230.20216.68
7.3.80.0130.12716.80
7.3.70.0160.11916.73
7.3.60.0060.13316.59
7.3.50.0070.12516.70
7.3.40.0120.12816.66
7.3.30.0060.12516.69
7.3.20.0160.13418.53
7.3.10.0100.19418.55
7.3.00.0060.17118.54
7.2.340.0030.16716.86
7.2.330.0130.15016.97
7.2.320.0100.15016.95
7.2.310.0060.17016.97
7.2.300.0100.17617.11
7.2.290.0130.14716.99
7.2.280.0130.17816.94
7.2.270.0060.17517.09
7.2.260.0070.15316.98
7.2.250.0190.14116.85
7.2.240.0030.14816.84
7.2.230.0100.16716.99
7.2.220.0070.14616.96
7.2.210.0120.16916.92
7.2.200.0130.15016.91
7.2.190.0100.14516.95
7.2.180.0060.21716.99
7.2.170.0100.16516.90
7.2.160.0060.15216.78
7.2.150.0090.16218.68
7.2.140.0170.16018.70
7.2.130.0130.15518.82
7.2.120.0170.17118.89
7.2.110.0030.15118.90
7.2.100.0170.15918.60
7.2.90.0190.19518.66
7.2.80.0130.18118.72
7.2.70.0100.16118.70
7.2.60.0100.15618.71
7.2.50.0130.16718.97
7.2.40.0190.19618.78
7.2.30.0210.15418.71
7.2.20.0060.15218.68
7.2.10.0070.16818.77
7.2.00.0180.14318.77

preferences:
21.88 ms | 401 KiB | 5 Q