Php write file as file,file2,file3 etc

$name = 'folder/file.txt';
$actual_name = pathinfo($name,PATHINFO_FILENAME);
$original_name = $actual_name;
$extension = pathinfo($name, PATHINFO_EXTENSION);
$i = 2;
$actual_name = (string)$original_name.$i;
$name = $actual_name.".".$extension;
$myfile = fopen('folder/'.$name, "w") or die("Unable to open file!");
$txt = "This is content to write";
fwrite($myfile, $txt);

Share on Facebook0Tweet about this on Twitter0Share on Google+0Pin on Pinterest0Share on LinkedIn0Share on Reddit0
It's only fair to share...

Add Comment

Required fields are marked *. Your email address will not be published.