TABLEborder0cellPadding0cellSpacing0height100 % width100 % (PHP3, PHP44.0.0) trim -- removes the blank description stringtrim (stringstr [, stringcharlist]) at the beginning and end of a string. note: the second parameter is used in the function PHP4.1.0 to return the str word tag: manual
TABLE border = 0 cellPadding = 0 cellSpacing = 0 height = "100%" width = "100%">
(PHP 3, PHP 4> = 4.0.0)
Trim -- removes spaces at the beginning and end of a string.
Description
String trim (string str [, string charlist])
Note: The second parameter is used in PHP 4.1.0.
This function returns the new string after the str string is removed from the first and last spaces. Without the second parameter trim (), the following characters are removed:
"" (ASCII 32 (0x20), space;
"\ T" (ASCII 9 (0x09), tab;
"\ N" (ASCII 10 (0x0A), line break;
"\ R" (ASCII 13 (0x0D), carriage return;
"\ 0" (ASCII 0 (0x00), empty character;
"\ X0B" (ASCII 11 (0x0B), vertical tab.
You can use the charlist parameter to specify the characters you want to remove. Simply list all characters that you want to be stripped. With... you can specify a range of characters.
Example 1. trim ()
$ Text = "\ t \ tThese are a few words :)...";
$ Trimmed = trim ($ text );
// $ Trimmed = "These are a few words :)..."
$ Trimmed = trim ($ text, "\ t .");
// $ Trimmed = "These are a few words :)"
$ Clean = trim ($ binary, "\ 0x00 .. \ 0x1F ");
// Trim the ASCII control characters at the beginning and end of $ binary
// (From 0 to 31 random sive)
?>
See ltrim () and rtrim ().