0

What im tryig to do is add one line of code to all files at once
Can this even be done ?
I have tried reading all files in a directory then fopen to fwrite without any success.
Any ideas ?
Thank you

2
Contributors
3
Replies
10
Views
4 Years
Discussion Span
Last Post by Tko_1
0

Files that are stored on the server, or, local machine? What do you mean "had no success" - What happened? Errors?

0

I am sry should of posted some script..
well this is what i have tried

<?php 
    $folder=dir("./");
        while($folderEntry=$folder->read())
        {
        echo $folderEntry."<br>";
        }
    $fh = fopen($folderEntry, 'a') or die("can't open file");
    $stringData = "test\n";
    fwrite($fh, $stringData);
    fclose($fh);
        $folder->close();
        ?>

with an error of:
Warning: fopen() [function.fopen]: Filename cannot be empty on line 7

0

okay wow i got this to work but now how to include any and all sub directorys, any ideas ??

<?php
$dirname = "./";
$dirread = opendir($dirname);
while(false != ($file = readdir($dirread)))
{
if(($file != ".") and ($file != ".."))
{
$dir='./'.$file.'';
$myFile = ''.$dir;
$fh = fopen($myFile, 'a') or die("can't open file");
$content = "content" . "</br>";
fwrite($fh, $content);
fclose($fh);
}}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.