Hi peeps, just wondering if you could help me again. How can I extract lines from a text document, say... lines 1, 2, 3, 4, 10, 11, 12 etc etc and write it to another new document?
Hope you can help!
read the document line by line in a while loop -- and put a counter in the lop as well. if the counter = a line you want, store it. otherwise, ignore it
sorry, but how would that code be written?
<?php $counter=0; $linelist=array(1,2,3,4,5,6,7,8,9,10); $handle = fopen("/tmp/inputfile.txt", "r"); while (!feof($handle)) { $buffer = fgets($handle, 4096); if(in_array($counter,$linelist)){ echo $buffer; } $counter++; } fclose($handle); ?>
Hey thanks very much! I wrote a simliar code but with many errors, I'm starting to get the hang of this php stuff. Thanks very much for your help!