nehashri Posted June 11, 2008 Share Posted June 11, 2008 hello every one I am trying to display my data which is present in a textfile (data.txt) format. I have to display this file as it is (the format of the file should not change) in a new window when a user asks for it. to be more precise- I have a data.txt file which contain information about computers....these are in perticular format which i dont want to change. Now when a user from the front end ask for this data it should disply it in a new window (IE) or may in a textarea (inside a form) in a new window (IE)... please if any one can help me with this Neha Link to comment https://forums.phpfreaks.com/topic/109702-display-text-file-data-to-textarea-using-php/ Share on other sites More sharing options...
Orio Posted June 11, 2008 Share Posted June 11, 2008 Try something like this: <?php $data = file_get_contents("data.txt"); echo nl2br(htmlentities($data)); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/109702-display-text-file-data-to-textarea-using-php/#findComment-562944 Share on other sites More sharing options...
nehashri Posted June 12, 2008 Author Share Posted June 12, 2008 hey thanks for the reply.... but i guess i have figured out a much easier way for this....by using <pre></pre> html tags i m able to solve my probs regards neha Link to comment https://forums.phpfreaks.com/topic/109702-display-text-file-data-to-textarea-using-php/#findComment-563782 Share on other sites More sharing options...
Orio Posted June 12, 2008 Share Posted June 12, 2008 That's an option, but just keep in mind that if you have HTML tags inside that text file, they will be parsed. That's why I preferred using nl2br() with htmlentities(). Orio. Link to comment https://forums.phpfreaks.com/topic/109702-display-text-file-data-to-textarea-using-php/#findComment-563785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.