Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

erase the "line break" in a string

Status
Not open for further replies.

Kicket

Technical User
Jun 15, 2002
155
US

ereg_replace("\n","",$string)

i basically want get rid off those "enter"s
i tried the code above doesn't work
anyone know the code for "enter"?

ff
 
chr(13) Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 

$abox=ereg_replace("1|2|3|4|5|6|7|8|9|0| | |\n|\r|/\r|/n| ","",$abox);

okay thanks for help everyone
i figure out the code above, it seems to fix the problemh
it tookout white space, enter, and numbers



ff
 
Rather than using the ereg_ family of regular expression functions, I recommend you take a look at the preg_ family of regular expression functions.

This from the PHP online manual from the seciont introducing the ereg_ family of functions:

[tt]Note: PHP also supports regular expressions using a Perl-compatible syntax using the PCRE functions. Those functions support non-greedy matching, assertions, conditional subpatterns, and a number of other features not supported by the POSIX-extended regular expression syntax.[/tt] ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
thanks for point that out
but i think preg is only good for verify a string

ff
 
why not the

str_replace($string,"\n","")?

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
rtrim($string);
or
$string=preg_replace("/\n/","",$string);

It relly depends on how th efile was created, windows (DOS) and UNIX do things differently. \n for windows and \l\r for unix files.
rtrim works well because it indiscriminately removes th efinal character of whitespace. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
in linux i think it's \r\n. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
It is, but I'm so used to SCO :) whatever rtrim should be the tool for the job, it's not let me down yet [lol] ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top