-4

How to process big text file in PHP? In python one can use generators and read file just line by line without loading whole file to memory. Is there something like generators in PHP?

Harald Brinkhof
  • 4,375
  • 1
  • 22
  • 32
ashim
  • 24,380
  • 29
  • 72
  • 96
  • if you search on SO you'll find this question answered many times capoluca, i've flagged your question as a possible duplicate of http://stackoverflow.com/questions/4822165/php-read-large-text-file-log read it and you'll understand how to do what you want to do. – Harald Brinkhof Jun 24 '12 at 17:48
  • possible duplicate of [Reading very large files in PHP](http://stackoverflow.com/questions/162176/reading-very-large-files-in-php) – ashim Jul 17 '12 at 20:20

1 Answers1

1

you can run your php script in batch command ...

make a new file (run.bat) right click and edit and put this in the file :

c:/PHP/php.exe -f .\yourscript.php

change the url to php.exe and to yourscript.php to where its located then loop true the file with this :

<?php
$data=file("the big file.txt");
$lines=count($data);

$x=0;
while($x<=$lines){

print $data[$x]."\n";

sleep(1); //print out new line every 1 sec 

$x++;}
Al Kimpone
  • 50
  • 1
  • 8