Reputation: 48485
i'm wondering how to check if a string like : http://www.reddit.com/xxx/x/xxx contains the word : reddit.com
that string could contains or not contains reddit.com
and if it contains , it execute my function : itsReddit()
maybe with preg match? or something like this?
Please i don't want a link for tutorial, i only need a php code for this, & THANKS soo much!
Upvotes: 0
Views: 1678
Reputation: 96159
$input = 'http://www.reddit.com/xxx/x/xxx';
if ( false!==stripos($input, 'reddit.com') ) {
//itsReddit();
echo 'reddit';
}
Or if you want to test if the host is reddit.com
$input = 'http://www.reddit.com/xxx/x/xxx';
$host = parse_url($input, PHP_URL_HOST);
if ( false!==stripos($host, 'reddit.com') ) {
//itsReddit();
echo 'reddit';
}
Upvotes: 2