我有一个标签
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit</p>
我需要像这样改变它:
<p>Lorem ipsum dolor sit <span id='aaa'> amet, consectetuer </span> adipiscing elit</p>
我的代码是这样的:
$doc = new DOMDocument();
$doc->loadHTMLFile($url);
$elementTarget = $doc->getElementsByTagName(strtolower('p'));
foreach($elementTarget as $elementValue) {
if (strcmp($elementValue->nodeValue), $searchPString) === 0)