3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_POST['contentDetails'] = '<p>This is data sample.&nbsp;</p><p>Second part of the paragraph.&nbsp;</p>'; $xml = '<?xml version="1.0" encoding="UTF-8">'; $xml .= '<root>'; $xml .= '<myData>'; $xml .= '<content>' . htmlentities(str_replace("&nbsp;", "", $_POST['contentDetails'])) . '</content>'; $xml .= '</myData>'; $xml .= '</root>'; echo $xml;
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.13
<?xml version="1.0" encoding="UTF-8"><root><myData><content>&lt;p&gt;This is data sample.&lt;/p&gt;&lt;p&gt;Second part of the paragraph.&lt;/p&gt;</content></myData></root>

preferences:
332.01 ms | 407 KiB | 5 Q