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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions + ereg issue

Status
Not open for further replies.

Screamsid

Programmer
May 14, 2003
20
GB
Hi, i'm making a back end control panel for a website of mine and i'm trying to find out how i would be able to strip /n and replace them with <BR>. Also when the script see's ' it replaces it with /'

I know you can write this into once ereg_replace expression, but was wondering if it's able to use the same ereg to do both jobs on the same string?

this is what i have so far

function nremover($msg){
$str = $msg;
$pat = &quot;/n&quot;;
$rep = &quot;<BR>&quot;;
return ereg_replace($pat, $rep, $str);
}
 
Just a note:
Your function wouldn't work anyway. The newline character is &quot;\n&quot; not with a forward slash.
Follow sleipnir's advice. The nl2br() actually creates <br/> XHTML compliant tags.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top