Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Reading From File</title>
- </head>
- <?php
- $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
- $filename = $DOCUMENT_ROOT.'learning php/css/'.'basic_2.txt';
- $line_in_file = count(file($filename));
- $fp = fopen($filename, 'r'); //this opens the file for reading
- for ($ii = 1; $ii <= $line_in_file; $ii++)
- {
- $line = fgets($fp); //reads one line from the file
- $city = trim($line);
- }
- fclose($fp);
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment