- var_dump: documentation ( source)
- html_entity_decode: documentation ( source)
- preg_replace: documentation ( source)
<?php
$before = html_entity_decode(" ") . " abc xyz ";
$pattern = '~^(\xC2\xA0| )*(.*?)(?1)*$~';
$after = preg_replace($pattern, '$2', $before);
var_dump($before, $after);