PhotonicCoder Posted October 5, 2011 Share Posted October 5, 2011 Ok Basically I need to know how to do this: I upload a txt file that contains this: "MLE ",20,"2057NALL ","ND ","Amber for 2057 1 ","!Amber for 2057 ",00003.65,00001.02 "MLE ",20,"211-2 ","D ","Dome-Courtesy 10 ","!Dome-Courtesy 1 ",00001.60,00000.61 How would I get Information from each different line like the below: 2057NALL | Amber for 2057 1 | 00003.65 | 00001.02 211-2 | Dome-Courtesy 10 | 00001.60 | 00000.61 Any help on this subject would be greatly appreciated. PhotonicCoder Quote Link to comment https://forums.phpfreaks.com/topic/248520-how-do-i-use-and-gather-information-from-a-txt-file-that-has-been-uploaded/ Share on other sites More sharing options...
PhotonicCoder Posted October 5, 2011 Author Share Posted October 5, 2011 I have already created the upload script and I think the answer may lie in this: http://www.tizag.com/phpT/fileread.php Quote Link to comment https://forums.phpfreaks.com/topic/248520-how-do-i-use-and-gather-information-from-a-txt-file-that-has-been-uploaded/#findComment-1276257 Share on other sites More sharing options...
PhotonicCoder Posted October 5, 2011 Author Share Posted October 5, 2011 Ok here is something: This will get everything 5 spaces in on the line <?php fread($fh, 5); ?> And this will get the amount of lines: <?php $lines = file("upload/" . $_FILES["file"]["name"]); $lineCount = count($lines); ?> But how do I choose the Individual line and get information from certain parts of the text? PhotonicCoder But how Quote Link to comment https://forums.phpfreaks.com/topic/248520-how-do-i-use-and-gather-information-from-a-txt-file-that-has-been-uploaded/#findComment-1276262 Share on other sites More sharing options...
PhotonicCoder Posted October 7, 2011 Author Share Posted October 7, 2011 40 views and no help... BUMP Quote Link to comment https://forums.phpfreaks.com/topic/248520-how-do-i-use-and-gather-information-from-a-txt-file-that-has-been-uploaded/#findComment-1276626 Share on other sites More sharing options...
jcbones Posted October 7, 2011 Share Posted October 7, 2011 Your question is pretty ambiguous. As in, no one really understands the question. <?php $lines = file("upload/" . $_FILES["file"]["name"]); echo '<pre>'; for($i = 0; $i < $lineCount; $i++) { if(empty($lines[$i])) { continue; } $parts = explode(',',$lines[$i]); echo str_replace('"','',$parts[2]) . ' | ' . str_replace('"','',$parts[4]) . ' | ' . str_replace(array('"','!'),'',$parts[5]) . ' | ' . $parts[6] . ' | ' . $parts[7] . "\n"; } echo '</pre>'; In it's simplest form. Quote Link to comment https://forums.phpfreaks.com/topic/248520-how-do-i-use-and-gather-information-from-a-txt-file-that-has-been-uploaded/#findComment-1276641 Share on other sites More sharing options...
PhotonicCoder Posted October 7, 2011 Author Share Posted October 7, 2011 Unfortunately realized that this was ambiguous, however Thank you so much for this so I can get farther down the road. I will mark this topic solved after I go over it. Thank you again for that jcbones! PhotonicCoder Quote Link to comment https://forums.phpfreaks.com/topic/248520-how-do-i-use-and-gather-information-from-a-txt-file-that-has-been-uploaded/#findComment-1276890 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.