trim function not clear

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
husniteja
Forum Newbie
Posts: 10
Joined: Fri Feb 25, 2005 8:33 pm
Location: south korea

trim function not clear

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply