September 2001
Intermediate to advanced
768 pages
32h 45m
English
string trim(string string) Removes whitespace from the left and right ends of a string.
Returns:
String
Description:
trim() removes all whitespace characters from both the left and right ends of a string. The function considers the following characters to be whitespace:
| Character Name | ASCII Value | PHP Character Escape Sequence |
|---|---|---|
| null | 0 | \0 |
| tab | 9 | \t |
| newline | 10 | \n |
| vertical tab | 11 | none |
| carriage return | 13 | \r |
| space | 32 | none |
Version:
PHP 3+, PHP 4+
See also:
To strip whitespace from the start or end of a string:
chop() ltrim() rtrim()
Example:
<?php if (count ($HTTP_POST_VARS)) { $name = trim ($HTTP_POST_VARS['name']); if ($name) { echo ("<b>$name</b>: There are some who ... |
Read now
Unlock full access