davemcc Posted October 10, 2007 Share Posted October 10, 2007 Hello I am looking for some more experienced help here! I wish to display .txt files within a php page. I have found out how to do this but any formatting such as paragraphs and tabs is lost. Can anyone help me with how to display the txt file as it is, formatting included? It is simply so we can update our Community Centre website with ease via txt files. Hope someone can help Cheers Dave Quote Link to comment https://forums.phpfreaks.com/topic/72587-displaying-txt-files-and-maintainint-their-format-using-php/ Share on other sites More sharing options...
tibberous Posted October 10, 2007 Share Posted October 10, 2007 Just typed this into the editor so there might be bugs - thats basically it though. $lines = file("yourfile.txt"); echo '<pre>'; foreach($lines as $line) echo str_replace("<", "<", $line)."\n"; echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/72587-displaying-txt-files-and-maintainint-their-format-using-php/#findComment-366050 Share on other sites More sharing options...
davemcc Posted October 10, 2007 Author Share Posted October 10, 2007 That works great! Many thanks! The only thing i am having a prob with is when its formatted with css the font cannot be changed. all other formatting seems ok! Any ideas? Thanks again Dave Quote Link to comment https://forums.phpfreaks.com/topic/72587-displaying-txt-files-and-maintainint-their-format-using-php/#findComment-366060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.