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

<?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

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);
}}
?>
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.