Jump to content


Removing the n\


2 replies to this topic

#1 PartDigital

    Young Padawan

  • Members
  • Pip
  • 6 posts

Posted 07 May 2007 - 09:06 PM

I would like to convert this:

a bunch of html
for your viewing pleasure

to this:

a bunch of html for your viewing pleasure

ereg_replace("\n", "", $string) doens't work

neither does str_replace("\n", "", $string);

#2 Pooch

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 07 May 2007 - 09:42 PM

View PostPartDigital, on May 7 2007, 10:06 PM, said:

I would like to convert this:

a bunch of html
for your viewing pleasure

to this:

a bunch of html for your viewing pleasure

ereg_replace("\n", "", $string) doens't work

neither does str_replace("\n", "", $string);

Try this:
<?
$string = ereg_replace('\\\n','',$string);
?>

Use single quotes and escape the '\' and 'n'. Did that work for you?

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 08 May 2007 - 12:58 AM

Are you sure it's not working? If you are on windows, you also have to remove \r.
preg_replace('#(\r\n|\r|\n)#s', '', $text);






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users