How do I remove extra lines out of text before it is written to a file..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CMNetworx
    New Member
    • Jan 2007
    • 4

    How do I remove extra lines out of text before it is written to a file..

    ok, so I am grabbing a file off of my server, and I strip out all of the html tags and extra crap that I don't want, and write it to a text file, however the content that makes it to the file still looks something like this

    value

    value2

    and sofourth, I have tried using trim to remove the extra hard returns, but no luck
    [php]
    $theData = trim($theData, "\r");
    $theData = trim($theData, "\n");[/php]

    The end result I would be looking for is
    value
    value2

    any body have any ideas?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    These statements only remove the \r and \r and not the other white space characters. When you want to remove ALL white space chars you do not specify a character in the trm() statement. So it is just trim($string);.
    This function returns a string with whitespace stripped from the beginning and end of str. Without the second parameter, trim() will strip these characters:

    " " (ASCII 32 (0x20)), an ordinary space.
    "\t" (ASCII 9 (0x09)), a tab.
    "\n" (ASCII 10 (0x0A)), a new line (line feed).
    "\r" (ASCII 13 (0x0D)), a carriage return.
    "\0" (ASCII 0 (0x00)), the NUL-byte.
    "\x0B" (ASCII 11 (0x0B)), a vertical tab.
    Ronald :cool:

    Comment

    Working...