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

line breaks when reading a file

P: n/a
Consider the code:

$arrText = file ("http://www.site.com/page.htm");
for ($i=0; $i<count($arrText); i++) {
echo("$arrText[$i]\n");
}

(I did not test the snippet for errors)

The line breaks appear to be different from the original .htm file. Why?

Best,
Christopher
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Christopher Glaeser wrote:
$arrText = file ("http://www.site.com/page.htm");
for ($i=0; $i<count($arrText); i++) {
echo("$arrText[$i]\n");
}

(I did not test the snippet for errors)

The line breaks appear to be different from the original .htm file.


You're adding a linefeed character to each line of the original
source. Newlines aren't stripped by file; to remove them, the Manual
suggests rtrim. (It actually says you "*need* [emphasis added] to use
rtrim()".)

http://www.php.net/manual/en/function.file.php

--
Jock
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.