3v4l.org

run code in 300+ PHP versions simultaneously
<?php function urlHasString($url, $strings) { foreach($strings as $string) { if(strpos($url, $string)) { return true; } } return false; } $url = 'www.test.com#stuff'; $strings = ['#', 'java', 'jpg', 'jpeg', 'png', 'tel']; if(urlHasString($url, $strings)) { echo 'Yes it contains one of the strings'; } else { echo 'No it does not contain any of the strings'; }
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Yes it contains one of the strings

preferences:
107.67 ms | 1671 KiB | 4 Q