Current location: Hot Scripts Forums » Programming Languages » PHP » How to do fopen all files at a time and show one line from all files.


How to do fopen all files at a time and show one line from all files.

Reply
  #1 (permalink)  
Old 03-01-04, 08:33 PM
Mouse Mouse is offline
New Member
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
How to do fopen all files at a time and show one line from all files.

I already know the simple fopen for reading single file.

but i have problem.

I want to do this

I have a folder with 20 text files and it has few texts in it. and I want to make a script that will read all 20 files and echo the 2nd line into html file or in your IE broswer.


<?


// Define the full path to your folder from root
$path = "E:\web\-= php read =-";



//////////////////////////

/// how could put whole dir in this ???

$fp = @fopen("pizza.txt", "rb") or die("Couldn't open file");
while(!feof($fp))
{
$data .= fgets($fp, 1024);
}

fclose($fp);

$values = explode("\r\n", $data);

echo $values[1] . "<p>";


//////////////////////////////////


// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");

// Loop through the files
while ($file = readdir($dir_handle)) {

if($file == "." || $file == ".." || $file == "index.php" )

continue;
echo "<a href=\"$file\">$file</a><br />";

}

// Close
closedir($dir_handle);

?>
Reply With Quote
Reply

Bookmarks

« i-faker | Cheats »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 09:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.