$pattern = "/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))/";
$str = file_get_html($_GET['url'])->plaintext;
if($num_found = preg_match_all($pattern, $str, $out)) {
print_r($out[0]);
}
Output
Array ([0] => https://ssl.gstatic.com/gb/images/b_8d5afc09.png [1] => https://ssl.gstatic.com/gb/images/b8_3615d64d.png [2])
因此,现在我想查找以下任何链接是否包含某些特定单词,例如“b_8d5afc09”,然后我想获取该链接并仅显示该链接。
到目前为止,我已经尝试过使用“in_array”,但即使链接存在,它也永远找不到,我做错了什么吗?任何建议表示赞赏!
if (in_array("b_8d5afc09", $out[0]))
{
echo "found";
}
else
{
echo "nope";
}
慕森王