Connecting Tech Pros Worldwide Forums | Help | Site Map

How to detect a line break in a multiline textfield

Ciaran
Guest
 
Posts: n/a
#1: Feb 28 '07
Hi can someone give me the code to convert a line break in a multiline
textfield to a <br/tag ? It's something to do with CR LF but I can't
find the exact code anywhere.
Cheers,
Ciarán


Hendri Kurniawan
Guest
 
Posts: n/a
#2: Feb 28 '07

re: How to detect a line break in a multiline textfield


Ciaran wrote:
Quote:
Hi can someone give me the code to convert a line break in a multiline
textfield to a <br/tag ? It's something to do with CR LF but I can't
find the exact code anywhere.
Cheers,
Ciarán
>
nl2br
Hendri Kurniawan
Guest
 
Posts: n/a
#3: Feb 28 '07

re: How to detect a line break in a multiline textfield


Hendri Kurniawan wrote:
Quote:
Ciaran wrote:
Quote:
>Hi can someone give me the code to convert a line break in a multiline
>textfield to a <br/tag ? It's something to do with CR LF but I can't
>find the exact code anywhere.
>Cheers,
>Ciarán
>>
nl2br
Sorry, Need to clarify this.
nl2br converts line break to HTML br tag.
If you want to change from <br/tag to CRLF, do a str_replace instead.
I've no recollection any functions that will convert br tag to CRLF
(as far as i know anyway)

Hendri Kurniawan
Ciaran
Guest
 
Posts: n/a
#4: Feb 28 '07

re: How to detect a line break in a multiline textfield


Thanks for the reply Hendri. I got it sorted out using a simple find
and replace I found by searching for nl2br thanks to your second
post.

Converting textarea line breaks to <brin PHP
$result = str_replace(array("\r\n", "\r", "\n"), "<br />",
$thestring);

Converting <brto textarea line breaks in PHP:
$result= str_replace(array("<br/>", "<br>", "<br />"), "\n",
$thestring);

Hope this helps someone,
Ciarán

Closed Thread


Similar PHP bytes