I need help with a preg-pattern for preg_replace_callback(). I need to match <td(+all properties)> and replace them with <td id=$counter>.
This is as far as I have come in my code: <?php $html = '<table border=1 id="myTable"> <tr> <td> <table border=1> <tr> <td width=20>tabell2 cell1</td> <td width=40>tabell2 cell2</td> </tr> </table> </td> <td>första cell i rad två</td> <td>Detta är den sista</td> </tr> </table>'; $counter = 0; function bla($matches) { global $counter; $counter++; return "<td id=\"theId".$counter."\">"; } // this pattern is all wrong, since it matches and replaces all tags echo preg_replace_callback("|(<[td][^>]+>)|i", "bla", $html); ?> Any thoughts? // Tobias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php