php dom add class to element code example
Example: php dom add class to element
$dom = new DOMDocument;
$dom->loadHTML($html);
$divs = $dom->getElementsByTagName('div');
foreach ($divs as $div) {
$div->setAttribute('class', $div->getAttribute('class').' myclass');
}
$html = $dom->saveHTML();