<?php $content = "<table> <tr> <td>AAA</td> <td>30,40 €</td> <td>41,10 €</td> </tr> <tr> <td>BBB</td> <td>30,40 €</td> <td>41,10 €</td> </tr> <tr> <td>CCC</td> <td>30,40 €</td> <td>41,10 €</td> </tr> </table>"; $doc = new DOMDocument(); $doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($doc); foreach ($xpath->query('//td[1]') as $td) { $td->setAttribute('class', 'first'); } echo $doc->saveHTML();
You have javascript disabled. You will not be able to edit any code.