News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

text lf question

Started by andrea, August 17, 2003, 10:41:18 AM

Previous topic - Next topic

andrea

How to include a text file such that the line separators contained in the text file are parsed?

Example:

http://www.yabbse.org/community/attachments/YaBB_SE_modifications_TOS.txt

There you see the text has some line delimiters. Now I include this text in a php file with this simple code:

<?php

include("http://www.yabbse.org/community/attachments/YaBB_SE_modifications_TOS.txt");

?>


The output of this php file you see here:
http://hubacher.net/yabbse-mod-tos.php

Alle line delimiters, feeders etc. are gone. What am I doing wrong? I did already try to store the text file on my local server disk and include from there, this did not help.

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Zef Hemel

Beside the fact that it's very inefficient to use inlcude with URLs, you should always use paths if possible. This might work:
<?php

echo nl2br(implode('', file('http://www.yabbse.org/community/attachments/YaBB_SE_modifications_TOS.txt')));

?>

[Unknown]

Quote from: Zef Hemel on August 17, 2003, 10:57:52 AM
Beside the fact that it's very inefficient to use inlcude with URLs, you should always use paths if possible. This might work:
<?php

echo nl2br(implode('', file('http://www.yabbse.org/community/attachments/YaBB_SE_modifications_TOS.txt')));

?>


I would personally do it like this...

echo nl2br(htmlspecialchars(implode('', file('http://www.yabbse.org/community/attachments/YaBB_SE_modifications_TOS.txt'))));

Or, for versions of PHP above 4.3.x...

echo nl2br(htmlspecialchars(file_get_contents('http://www.yabbse.org/community/attachments/YaBB_SE_modifications_TOS.txt')));

-[Unknown]

Aquilo

I guess these php books might come in handy I never knew about the nl2br() function :(

I would have done the fopen, while loop, and str_replace thing :P
what would be the BEST php book?

Spaceman-Spiff


Advertisement: