我在标签上运行 strpos<a>来查看它是否包含两个 url 之一。
目前我正在使用这个波纹管 - 我将如何设置它来检查 - tumblr.com 或 google.com 是否存在?
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>";
}
Run Code Online (Sandbox Code Playgroud)
strpos 中不能使用两根针。但你可以做的是使用它两次,并使用 or :
function find_excluded_url ($url) {
return (strpos($url, "tumblr.com")!==false) || (strpos($url, "google.com")!==false);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1798 次 |
| 最近记录: |