- var_dump: documentation ( source)
- html_entity_decode: documentation ( source)
- preg_replace: documentation ( source)
<?php
var_dump(preg_replace('/^\s(.*)\s$/u', '$1', preg_replace('/(\s)\s+/u', '$1', html_entity_decode(' test ', ENT_QUOTES, 'utf-8'))));