How to check if URL contain certain string using PHP

 <?php 

// Given URL 
$url = '/tools2/category/assets/js/jquery4a5f.js?ver=1.12.4-wp'; 
  
// Search substring  
$key = 'category'; 
  
if (strpos($url, $key) == true) { 
    echo $key . ' exists in the URL <br>'; 

else { 
    echo $key . ' not  exists in the URL <br>'; 
}  
?> 

Post a Comment

0 Comments