Jump to content

Need help with Line Breaks, but in reverse...


alexcmm

Recommended Posts

Hello,

I'm hoping there's an easy way to turn a <BR> back into something else... preferrably a space. I'm using this code to turn a

/n

into a

<BR>

 

	$program=$_POST['program'];
$program = preg_replace("/\n/","\n<BR>\n",$program);

 

How can I do the reverse? Can you help?

You should be using the function nl2br() to add the <br /> tag before the newline characters "\n". Then to remove them and just leave the newline characters do a

<?php
$line = str_replace("<br />\n","\n",$line);
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.