Page 1 of 1

trim function not clear

Posted: Tue Mar 08, 2005 6:13 pm
by husniteja
dear all

suppose i use the code from PHP manual :

Code: Select all

$text = "\t\tThese are a few words  ...  ";
echo trim($text);          // "These are a few words  ..."
echo trim($text, " \t."); // "These are a few words "
echo trim($text, " .");   // "These are a few words "
from that code, i cannot figure out what the \t mean ? because with and without \t in line 3 and 4 have the same result.

And how to strip the other word, example i want to strip "world"

thanks


feyd | hey look at that,

Code: Select all

works [/color]

Posted: Tue Mar 08, 2005 6:40 pm
by feyd
the second argument of trim() is a string containing all characters to add to use as trimmable. Trim() by default, will remove all white-space around the first argument. \t is a tab, white-space.

str_replace() is often used to remove words and things. preg_replace() can be used for pattern replacement.