3v4l.org

run code in 500+ PHP versions simultaneously
<?php $re = '/<td.*?>.*?<p>(.*?)<\/p>.*?<\/td>/s'; $str = '<table width="652"> <tbody> <tr> <td colspan="2" width="652"> <p><strong>Test header</strong></p> </td> </tr> <tr> <td width="21"> <p>Nr.</p> </td> <td width="178"> <p><strong>Test2</strong></p> </td> </tr> <tr> <td rowspan="2" width="21"> <p>1</p> </td> <td rowspan="2" width="178"> <p>Test3</p> </td> </tr> </tbody> </table>'; $subst = '<td>$1</td>'; Echo "before: \n"; Var_dump($str); Echo "\n\nafter:\n"; $result = preg_replace($re, $subst, $str); Var_dump($result); //echo "The result of the substitution is ".$result;
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
before: string(326) "<table width="652"> <tbody> <tr> <td colspan="2" width="652"> <p><strong>Test header</strong></p> </td> </tr> <tr> <td width="21"> <p>Nr.</p> </td> <td width="178"> <p><strong>Test2</strong></p> </td> </tr> <tr> <td rowspan="2" width="21"> <p>1</p> </td> <td rowspan="2" width="178"> <p>Test3</p> </td> </tr> </tbody> </table>" after: string(187) "<table width="652"> <tbody> <tr> <td><strong>Test header</strong></td> </tr> <tr> <td>Nr.</td> <td><strong>Test2</strong></td> </tr> <tr> <td>1</td> <td>Test3</td> </tr> </tbody> </table>"

preferences:
97 ms | 1613 KiB | 4 Q