3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = <<<HTML <table> <thead> <tr> <th>1</th> <th>2</th> </tr> </thead> <tbody> <tr> <td> <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td>C</td> <td>D</td> </tr> </tbody> </table> </td> <td>4</td> </tr> </tbody> </table> HTML; var_dump( preg_replace_callback('~<table.*?</table>~is', function ($match) { return '<div>' . $match[0] . '</div>'; }, $content) );

preferences:
27.41 ms | 405 KiB | 5 Q