zenag Posted February 9, 2009 Share Posted February 9, 2009 hai to all ... i ve a text file test.txt s.no name ----------------------------- 1. hai 2. hello how to parse the above txt file to show output in php page .. 1. hai 2.hello Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/ Share on other sites More sharing options...
trq Posted February 9, 2009 Share Posted February 9, 2009 Sorry, you've lost me. Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/#findComment-757985 Share on other sites More sharing options...
RichardRotterdam Posted February 9, 2009 Share Posted February 9, 2009 what should the output be and in what format? have you looked into fopen? Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/#findComment-757994 Share on other sites More sharing options...
zenag Posted February 9, 2009 Author Share Posted February 9, 2009 thank u for ur reply.. i need the output to be array format like array([0]=>1.hai[1]=>2.hello) by removing the dashes(-------) in txt file Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/#findComment-758203 Share on other sites More sharing options...
premiso Posted February 9, 2009 Share Posted February 9, 2009 <?php $file = file_get_contents('test.txt'); $file = explode("-----------------------------", $file); $file = explode("\n", $file[1]); foreach ($file as $line) { echo $line . "<br />"; } ?> Should do the trick, explode file_get_contents and foreach Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/#findComment-758212 Share on other sites More sharing options...
zenag Posted February 9, 2009 Author Share Posted February 9, 2009 thank u very much...Mr.premiso... Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/#findComment-758218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.