我爬网以获得标题
$title = strip_tags($link1->plaintext);
但在结果中,有一个类似的结果Data Mining: Concepts and Techniques
如何删除它:
?谢谢你
我爬网以获得标题
$title = strip_tags($link1->plaintext);
但在结果中,有一个类似的结果Data Mining: Concepts and Techniques
如何删除它:
?谢谢你
问题是这:
是冒号的字符实体引用,但您的示例被错误地终止(缺少结束分号)。您可以使用以下(相当幼稚的)正则表达式修复未终止的引用:
$broken = "Data Mining: Concepts and Techniques";
$fixed = preg_replace('/(&#x?[a-e0-9]+)\b/i', '$1;', $broken);
然后您可以使用html_entity_decode
:
echo html_entity_decode($fixed); // Data Mining: Concepts and Techniques
$title = str_replace(":", "", strip_tags($link1->plaintext));