How to detect a line break in a multiline textfield

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ciaran

    #1

    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

  • Hendri Kurniawan

    #2
    Re: How to detect a line break in a multiline textfield

    Ciaran wrote:
    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

    Comment

    • Hendri Kurniawan

      #3
      Re: How to detect a line break in a multiline textfield

      Hendri Kurniawan wrote:
      Ciaran wrote:
      >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

      Comment

      • Ciaran

        #4
        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(arr ay("\r\n", "\r", "\n"), "<br />",
        $thestring);

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

        Hope this helps someone,
        Ciarán

        Comment

        Working...