+ Reply to Thread
Results 1 to 4 of 4

Thread: Line break while writing txt file using php & form data

  1. #1
    vaibhavy is offline x10Hosting Member vaibhavy is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    3

    Question Line break while writing txt file using php & form data

    I am writing (appending) a txt file with form data, using PHP. Since there are multiple form elements (textbox), i want each value to be written in txt file on new line.
    But out of "\n\r", "\r\n","\n" ,"\r" nothing is working. It just creates space and doesnt break the line please help.

  2. #2
    fortwienix is offline x10Hosting Member fortwienix is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    9

    Re: Line break while writing txt file using php & form data

    A normal "\n" in double quotes should do the trick.
    PHP Code:
    $fp fopen('your_file_name.txt''a+');
    fputs($fp$formfield_1."\n".$formfield_2."\n");
    fclose($fp); 
    "\r\n" is needed on Windows based systems.

  3. #3
    miguelkp's Avatar
    miguelkp is offline x10 Lieutenant miguelkp is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    El Bierzo - Spain
    Posts
    302

    Re: Line break while writing txt file using php & form data

    Hum. I think what you need are those functions:

    string nl2br(string) = you should input a string and a string outputs with every \n converted in a <br />

    string br2nl(string) = you should input a string and a string outputs with every <br /> converted in a <br />

    Edit: sorry, I didn't understand you. Forgot this.
    Last edited by miguelkp; 03-31-2010 at 07:33 AM.
    Clic on userbar to visit my band's website:

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Line break while writing txt file using php & form data

    Please show your code.
    Nothing is always absolutely so.

+ Reply to Thread

Similar Threads

  1. PHP writing to a file outside a directory
    By NightFox in forum Programming Help
    Replies: 3
    Last Post: 01-23-2009, 05:22 PM
  2. Replies: 6
    Last Post: 08-25-2008, 09:43 AM
  3. Line breaks in Form Data
    By Adam01 in forum Programming Help
    Replies: 8
    Last Post: 01-12-2008, 03:09 PM
  4. Created and writing form data a to CSV file
    By HeavyMetalMan in forum Free Hosting
    Replies: 0
    Last Post: 12-05-2007, 02:55 PM
  5. Problem writing to a file (php)
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 06-06-2006, 02:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers