RockLobsterInc\Functions

strip_whitespaces() │ CF7 1.0

Strips surrounding whitespaces.

Хуков нет.

Возвращает

string|array. Output text or array of text.

Использование

strip_whitespaces( string|array $input ): string|array;
string|array $input(обязательный)
.

Код strip_whitespaces() CF7 6.2.4.1

function strip_whitespaces(string|array $input): string|array
{
    if (is_array($input)) {
        return array_map(static function ($item) {
            return strip_whitespaces($item);
        }, $input);
    }

    $whitespaces =
        '\x09-\x0D\x20\xA0\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}';

    $input = scrub_utf8($input);

    $input = preg_replace(sprintf("/^[%s]+/u", $whitespaces), "", $input);

    $input = preg_replace(sprintf('/[%s]+$/u', $whitespaces), "", $input);

    return $input;
}