- preg_replace_callback: documentation ( source)
- str_replace: documentation ( source)
<?php
$text='<p > ¡Esto es una prueba! < /p > <p> <strong > Prueba 123 </strong> </p> <p> <strong> <a href="https://matricom.net"> MATRICOM < / a> </ strong> </p> <p> <strong > Todas las pruebas aquí ... </strong > < /p>';
echo preg_replace_callback('/<[^<>]+>/u', function($m) {
return str_replace(' ', '', $m[0]);
}, $text);