php - Using 2 or more needles when using strpos -
this question has answer here:
- using array needles in strpos 11 answers
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
Post a Comment