Код: Выделить всё
$string = " test string ";
echo preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string);
// outputs: test string
Подробнее здесь: https://stackoverflow.com/questions/648 ... spaces-php
Код: Выделить всё
$string = " test string ";
echo preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string);
// outputs: test string