Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 28th, 2007, 01:15 AM
Ciaran
Guest
 
Posts: n/a
Default How to detect a line break in a multiline textfield

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

  #2  
Old February 28th, 2007, 01:25 AM
Hendri Kurniawan
Guest
 
Posts: n/a
Default 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
  #3  
Old February 28th, 2007, 01:55 AM
Hendri Kurniawan
Guest
 
Posts: n/a
Default 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
  #4  
Old February 28th, 2007, 02:45 PM
Ciaran
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles