Вы можете использовать preg_replace
:
$text = "< > Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, < > when an <b>unknown printer</b> took <> a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries. < >";
$text = preg_replace('/<\s*\>/', '', $text);
echo $text;
Вывод:
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an <b>unknown printer</b> took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries.
Демонстрация на 3v4l.org
Если вы также хотите очистить несколько или висячих пробелов (в начале или конце строки) от удаления пустых <>
, вы можете использовать это вместо:
$text = preg_replace(array('/<\s*\>/', '/\s+/', '/^\s|\s$/'), array('', ' ', ''), $text);
Демо на 3v4l.org