trim()

Scalar. Returns a given string after removing trailing and leading spaces.

Syntax

trim ( string )

Parameters

string

A string. Works with UTF-8 strings.

Usage

Returns a given string after removing trailing and leading spaces. The function takes a string as the argument, and returns a string. The function returns the same value as applying ltrim() and rtrim() to a given string.

Example

trim (' examplestring ') returns 'examplestring'.

trim(' ') returns ''.

trim('a') returns 'a'.