Guest User

PHP probem

a guest
Dec 18th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Reading From File</title>
  6. </head>
  7.  
  8. <?php
  9.  
  10.     $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
  11.    
  12.     $filename = $DOCUMENT_ROOT.'learning php/css/'.'basic_2.txt';
  13.    
  14.     $line_in_file = count(file($filename));
  15.    
  16.     $fp = fopen($filename, 'r'); //this opens the file for reading
  17.    
  18.     for ($ii = 1; $ii <= $line_in_file; $ii++)
  19.         {
  20.             $line = fgets($fp); //reads one line from the file
  21.             $city = trim($line);
  22.         }
  23.     fclose($fp);
  24.  
  25. ?>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment