我有一些文字,其中有代码。我想从链接中获取最后一个文本。这是一个例子
Some text<a href="http://beezfeed.cu.ma">Beezfeed.cu.ma</a><br>
another text<a href="http://google.com">Google.com</a><br>
我想从上面的代码中获取Google.com文本。我尝试过使用Simple html dom。无论如何这是我的代码
<?PHP
require_once('simple_html_dom.php');
$html = new simple_html_dom();
function tags($ddd){
$bbb=$ddd->find('a',1);
foreach($bbb as $bs){
echo $bs->innertext;
}
}
$html = str_get_html('Some text<a href="http://beezfeed.cu.ma">Beezfeed.cu.ma</a><br>
another text<a href="http://google.com">Google.com</a><br>');
echo tags($html);
?>
我想让Google.com获得如何获得。请帮帮我
答案 0 :(得分:0)
我强烈建议您使用一些外部库来解析HTML。您需要的任何HTML。正如您今天或将来需要的那样。 一些非常好的工具在these stackoverflow post内命名。
我个人使用simplehtmldom.sourceforge.net,因为年龄非常好。