I have large text file that contain 800 K lines size 60 MB.I tried this code
$fileData = function() {
    $file = fopen('800K.txt','r');
    if (!$file)
        die('file does not exist or cannot be opened');
    while (($line = fgets($file)) !== false) {
        yield $line;
    }
    fclose($file);
};
foreach ($fileData() as $line) {
   echo $line.'<br>';
}
It really works : ).but con is it reads all line 800 K lines :( ....... it is possible convert into for loop , so it will be easy to selected line like
for ($i=1; $i<=10000; $i++){ 
$line=trim($lines[$i]); 
}
ANSWER :
$i=0;  //// start number
foreach ($fileData() as $line) {
   if($i==100) break;  ///// end number
   echo $line.'<br>';
   $i++; 
}
 
    