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

Recommended Answers

All 3 Replies

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

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

        echo $folderEntry."<br>";
    $fh = fopen($folderEntry, 'a') or die("can't open file");
    $stringData = "test\n";
    fwrite($fh, $stringData);

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

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

$dirname = "./";
$dirread = opendir($dirname);
while(false != ($file = readdir($dirread)))
if(($file != ".") and ($file != ".."))
$myFile = ''.$dir;
$fh = fopen($myFile, 'a') or die("can't open file");
$content = "content" . "</br>";
fwrite($fh, $content);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.