php - Using 2 or more needles when using strpos -


this question has answer here:

im running strpos on <a> tag see if contains either 1 of 2 urls.

at moment im using bellow - how set check if - tumblr.com or google.com present ?

function find_excluded_url ($url) {      $find = "tumblr.com"; // or google.com ....      $pos = strpos($url, $find);      if ($pos === false) {         return false;     } else {         return true;     } }    // set url    $url = "<a href='http://tumblr.com/my_post' rel='nofollow'>this site</a>";    // call func $run_url = find_excluded_url($url);  if ($run_url == true) {     echo "url - " . $url . "<br>"; } 

you can't use 2 needles in strpos. can do, use twice, or:

function find_excluded_url ($url) {   return (strpos($url, "tumblr.com")!==false) || (strpos($url, "google.com")!==false); } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -