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 Quote 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. Quote 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? Quote 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 Quote 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 Quote 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... Quote Link to comment https://forums.phpfreaks.com/topic/144441-parse-txt-file/#findComment-758218 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.