snippet library logo
in category
PHP / File Manipulation / Basic File Read
Snippet details
ID: 90
Viewed: 2187
Added: 2002-02-27
Version:
Sorry no demo

User Rated at: 3 Stars
Rate This:
Snippets in this catagory         
Show Printable Version
This little script will read a file that has information in it like this:

this
is
a
test

And it will display it on the screen as such.
If you want to print out a certain line you would just change the $i to a number and add it to $fileread[1] and that will print out the certain line.

General Details
Snippet uploaded by: snippet
Email : webmaster@snippetlibrary.com
Snippet By: snippet

<!---Head--->
none

<!---Body--->


<?
echo "<html>
<head>
<title></title></head>
<body>"
;
    
// opens the file to read
    
$fileread file("file.txt");
   
// counts all the lines in the file
    
$arrlen count($fileread);
   
//basic loop to print out to the screen according to the
      
for($i 0$i $arrlen$i++)
    {
        
//prints out the whole list.
       // if you want jsut a certain line, comment this one out.
         
echo"$fileread[$i]";
        
// this line will print out the second line in the file
       //remember that 0 is the first line of the file.
       
echo $fileread[1];
     }

echo
"</body></html>";
?>




No Reviews to show


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Subject:

Reviewed By:

Write a review:





Terms of Conditions
Powered By
Avian Hosting
© 2005 snippetlibrary.com All Rights Reserved.