SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cross platform newlines

    Whats the best way to convert new lines before inserting into mysql to make them all uniform/cross platform compatible?

    Would this work?

    $itext= preg_replace("/(\r\n|\n|\r)/", "\n", $text);

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your replace code will work for linux/unix but not in windows system. In windows system you should use \r\n. So compatible with all systems will be to use the <br> tag instead of \r\n but this will only work for printing in the web pages only not in the text areas or emails.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •