← All built-ins / trim()

trim()

trim(string $s): string

Parameters

NameTypeDescription
$sstringinput string

Return value

The string without leading or trailing whitespace.

Example

echo "[" . trim("   hello\n\t ") . "]";
[hello]

See also

ltrim()rtrim()