Hi
I have a file (test.txt) containing these lines
domain.com
domain2.com
domain3.com
...
domain100.com
I need to add domain101.com contained in $new_domain at the end of file
so I can have
domain.com
domain2.com
domain3.com
...
domain100.com
domain101.com
I am trying this
$file = "/usr/local/test.txt";
if (!file_exists("/usr/local/test.txt")) touch("/usr/local/test.txt");
$fh = fopen("/usr/local/test.txt", "r");
$fcontent = fread($fh, filesize("/usr/local/test.txt"));
$towrite = "$new_domain $fcontent";
$fh22 = fopen('/usr/local/test.txt', 'w+');
fwrite($fh2, $towrite);
fclose($fh);
fclose($fh2);
it doesn't work , it only create a blank file .
Is there a better way ?