Thursday, 30 April 2015

to find a value in url

       

        
$urlMatch = $_SERVER['REQUEST_URI'];
$pattern = '/[0-9]/';
if (preg_match($pattern, $urlMatch)) {
...
}
For matching value in array $corporate_gifts = array("wall clocks","crystal items","photo frame","showpiece","silver items","brass","religious item","tea set"); $whatINeed = explode('/', $link); $whatINeed = str_replace('-',' ',$whatINeed[3]); if(in_array($whatINeed,$corporate_gifts)):?> For matching in string $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (strpos($url,'car') !== false) { echo 'Car exists.'; } else { echo 'No cars.'; }

No comments:

Post a Comment