trim: take out white spaces

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
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

trim: take out white spaces

Post by vietboy505 »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a form for use to enter...

But sometimes people like to add many return carriage, new lines.

So I want to strip it out.. The below code doesn't work.  Why is that?

Is it because it's can't recogize as "hey \n\n\t"?

Code: Select all

explode("%_%",trim($_POST["PROBLEM"], " \t \n \r \s") );

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

$string = str_replace("\r", '', $string);
That will take 'em out.
Post Reply