PHPを使用して、最初のブロックのテキストを2番目のブロックのテキストに変換することは可能ですか?もしそうなら、どのように?ありがとう
<div>
<p>Some text & a <a href="http://abc.com/index.php?x=123&y=abc">link</a>. Done</p>
<p>More text & a <a href="http://abc.com/index.php?x=123&y=abc">link</a>. Done</p>
</div>
<div>
<p>Some text & a <strong>link</strong> <i>(http://abc.com/index.php?x=123&y=abc)</i>. Done</p>
<p>More text & a <strong>link</strong> <i>(http://abc.com/index.php?x=123&y=abc)</i>. Done</p>
</div>
編集。アンディの推薦によると、次のようなものを見てください。リンクの変換にはまだ苦労していますが、良いスタートのようです。
libxml_use_internal_errors(true); //Temporarily disable errors resulting from improperly formed HTML
$doc = new DOMDocument();
$doc->loadHTML($array['message_text']);
$a = $doc->getElementsByTagName('a');
foreach ($a as $link)
{
//Where do I go from here?
}
$array['message_text'] = $doc->saveHTML();
libxml_use_internal_errors(false);