Results 1 to 3 of 3

Thread: Insert break

  1. #1
    Join Date
    Jul 2006
    Posts
    142
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Insert break

    What I am trying to do is simple. When I get the data from a text area in a textbox in a form , here is what I am doing to put it in a doc file.

    Code:
    $resume = $_POST['resume'];
    
    $profile = $_POST['lname']."_"."Profile".$filedate.".doc";
    $profile = fopen($profile, "w") or die( "Error opening file" );
    
    flock ($profile, LOCK_EX);  
    
    $doc_content = "<html><head></head><body>
    				<b>Resume: </b> <br> $resume <br>
    				</body></html>";
    
    
    fwrite ($profile, $doc_content);
    Since it is a multiline text area, MS Word ignores the breaks in the text area.

    so if i put:

    Code:
    Since it 
    is a multiline 
    text area.
    It shows as

    Code:
    Since it is a multiline text area.
    I think the way to get that is to take it (textarea) in an array and then append a break tag (<br>) at the end of each line. Am I in the right direction? If so, how do i do it?

    Thanks

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    PHP Code:
    echo' < /br>; 
    PHP Code:
    echo "$resume\n"
    "\n" is parsed as new line, or line break. Or you can just force a <br> into the HTML (top option)

    The newline passed in an echo or print() is sent to the browser as
    string information, not formatting information. You need a <BR> tag in
    your code to create a line break in HTML.

    You can also use the nl2br(string myoutput) function to turn newlines
    into <BR> tags.
    PHP Code:
    nl2br("......\n"); 
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jul 2006
    Posts
    142
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thank you! nl2br() work perfectly.

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
  •