Cosizzle Posted December 3, 2009 Share Posted December 3, 2009 Hey guys, quick background on the project: Im migrating databases and to work in the old with the new. I'm writing a script which takes all the old data manipulates it to my needs then imports it into the database I have setup. Where I'm currently stuck is that there are .txt files that now need to go into the database. However these .txt files contain html. ie.<ul> and <li> tags. Using $var = file('file.txt'); I run into a problem in which the HTML is output. Would there be a way to encapsulate the text file within quotes; or another option? Thanks. Link to comment https://forums.phpfreaks.com/topic/183916-open-a-txt-with-html-embedded-in-it/ Share on other sites More sharing options...
premiso Posted December 3, 2009 Share Posted December 3, 2009 Would strip_tags solve your issue? Link to comment https://forums.phpfreaks.com/topic/183916-open-a-txt-with-html-embedded-in-it/#findComment-970900 Share on other sites More sharing options...
Cosizzle Posted December 3, 2009 Author Share Posted December 3, 2009 Yep that works, for now at least - I haven't thought far ahead as to what happens when the information comes back out of the database. Link to comment https://forums.phpfreaks.com/topic/183916-open-a-txt-with-html-embedded-in-it/#findComment-970901 Share on other sites More sharing options...
DavidAM Posted December 4, 2009 Share Posted December 4, 2009 Actually, I think you want to use htmlspecialchars() to display/edit the file contents in the browser. If you use strip_tags() and store it in the database, you will loose the markup. Link to comment https://forums.phpfreaks.com/topic/183916-open-a-txt-with-html-embedded-in-it/#findComment-971013 Share on other sites More sharing options...
Cosizzle Posted December 4, 2009 Author Share Posted December 4, 2009 DavidAM, that works out great, thanks kindly! Link to comment https://forums.phpfreaks.com/topic/183916-open-a-txt-with-html-embedded-in-it/#findComment-971426 Share on other sites More sharing options...
premiso Posted December 4, 2009 Share Posted December 4, 2009 Actually, I think you want to use htmlspecialchars to display/edit the file contents in the browser. Ah, yea. I was under the impression he did not want them at all, good call! Link to comment https://forums.phpfreaks.com/topic/183916-open-a-txt-with-html-embedded-in-it/#findComment-971464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.