如何使用源pdf找到所有anchor
标签
$string="hello this is a dummy text <a href="../../abc.pdf">
我只需要在字符串变量中abc.pdf
你应该使用 DOMDocument 而不是正则表达式:
$string='hello this is a dummy text <a href="../../abc.pdf">';
$doc = new DOMDocument;
$doc->loadHTML($string);
$href = $doc->getElementsByTagName('a')->item(0)->getAttribute('href');
echo basename($href); // abc.pdf