$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.';
}
It is all about programming. A blog about PHP, MYSQL, Javascript, Jquery,AJAX,HTML & CSS tutorial. Get short trick, knowledge based snippet for programming and technology related ideas.
Thursday, 30 April 2015
to find a value in url
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment