By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,053 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,053 IT Pros & Developers. It's quick & easy.

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

P: 4
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?
Jan 20 '07 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
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:
Jan 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.