<?php $content = '<table></table><p></p><table></table><p></p><table></table><p></p>'; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); libxml_use_internal_errors(false); $tables = $dom->getElementsByTagName('table'); foreach ($tables as $i => $table) { $table->setAttribute('class', "table_$i"); } echo $dom->saveHTML();
You have javascript disabled. You will not be able to edit any code.