trim()


string trim (string $str [, string $charlist ])

Description

trim() strips a white space (or other characters) from the beginning and end of a string

※ available F/W version : 1.3.1 ~

Parameters

Return values

Returns the modified string, PHP error on error

Example

<?php
hexdump(trim("\x0b\x00\x0d\x0a\x09\x20ABCDEFG\x0b\x00\x0d\x0a\x09\x20"));
// OUTPUT: 0000  41 42 43 44 45 46 47                          |ABCDEFG         |

echo trim(".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012345678.", "0123.45678"), "\r\n";
// OUTPUT: 9ABCDEFGHIJKLMNOPQRSTUVWXYZ

echo trim(".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012345678.", "0..3....4..8"), "\r\n";
// OUTPUT: 9ABCDEFGHIJKLMNOPQRSTUVWXYZ
?>

See also

ltrim() / rtrim()

Remarks

This function is identical to the PHP group's trim() function.