i have a following code......
$msg=addslashes(str_replace("\n","<br>",$message))
message is here text area.
here using str_replace i am replacing newline("\n") with <br> and instead of str_replace i want to do this using regular expression preg_replace.so how will i do it.its urgent thanx in advance
help regarding regular expression
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: help regarding regular expression
nl2br() converts newlines to line breaks for you
Re: help regarding regular expression
i have to use preg_replace only.its mandatory so how can i do it using preg_replace.......Jcart wrote:nl2br() converts newlines to line breaks for you
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: help regarding regular expression
What have you tried? And why is it mandatory? Sounds silly.
Re: help regarding regular expression
its mandatory bcoz it is told to do with that only and i don't know how to do it with preg-replace thts why i am asking