Gav's [gav at doesnotcompute.net] 25 lines of dribble included:
:>:>anyone know a way to remove the newlines that nl2br() creates?
:>its really annoying
:>im adding the text to a mysql db. which im sure works fine with newlines
:>in a field but i really dont want them :)
:>if i do a str_replace('\n', '', $text) it seems to remove the linefeed but
:>not the carriage return or something wierd.
$text = ereg_replace ("\n", "", $text);
Seems to work for me, however you could be working on Windows, in which case
you're going to have to take away the \r as well as the \n.
I'm usnig that on a UNIX system though and it works perfectly for me. However
I'm not sure why you want HTML entered into the database.
What would make sense to me would be to format the stuff when extracting out
of the database.
----------|
field |
----------|
hello<br> |
----------|
Your entering the HTML in the database, which IMHO is just plain wrong. It
should be entered as "hello" and then when extracted,
$string . "<BR>";
Hope it works either way,
Phil.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!