<?php
$html = '<body><div style="border:none;" class="classbutton" id="idstyle">Some text</div></body>';
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xpath = new DOMXPath($dom);
$divs = $xpath->query('//div[@class="classbutton"]');
foreach($divs as $div) {
$div->setAttribute('align', 'center');
$div->removeAttribute('style');
}
echo $dom->saveHTML();
PD9waHAKCiRodG1sID0gJzxib2R5PjxkaXYgc3R5bGU9ImJvcmRlcjpub25lOyIgY2xhc3M9ImNsYXNzYnV0dG9uIiBpZD0iaWRzdHlsZSI+U29tZSB0ZXh0PC9kaXY+PC9ib2R5Pic7CgokZG9tID0gbmV3IERPTURvY3VtZW50KCcxLjAnLCAnVVRGLTgnKTsKJGRvbS0+bG9hZEhUTUwoJGh0bWwsIExJQlhNTF9IVE1MX05PSU1QTElFRCB8IExJQlhNTF9IVE1MX05PREVGRFREKTsKCiR4cGF0aCA9IG5ldyBET01YUGF0aCgkZG9tKTsKJGRpdnMgPSAkeHBhdGgtPnF1ZXJ5KCcvL2RpdltAY2xhc3M9ImNsYXNzYnV0dG9uIl0nKTsKCmZvcmVhY2goJGRpdnMgYXMgJGRpdikgeyAKICAgJGRpdi0+c2V0QXR0cmlidXRlKCdhbGlnbicsICdjZW50ZXInKTsKICAgJGRpdi0+cmVtb3ZlQXR0cmlidXRlKCdzdHlsZScpOwp9CgplY2hvICRkb20tPnNhdmVIVE1MKCk7