irwan

fopen : read file to array

Nov 15th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.24 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $filename="input.txt";
  5. $lines = array();
  6. $file = fopen($filename, "r");
  7. while(!feof($file)) {
  8.  
  9.     //read file line by line into a new array element
  10.     $lines[] = fgets($file, 4096);
  11.  
  12. }
  13. fclose ($file);
  14. print_r($lines);
  15. ?>
  16.  
Advertisement
Add Comment
Please, Sign In to add comment