I am new in PHP and still learning about it. This time i want to print some text and save in a file. But i want the file names to be automatically changed.
For example file1.txt, file2.txt, file3.txt, and so on. Here's my code so far:
$read = file("example.txt",FILE_IGNORE_NEW_LINES);
$newFile = "file_1.txt";
$of = fopen($newFile,'w');
foreach($read as $k => $file){
$line = explode(" ",$file);
$line2 = array_slice($line,0,3);
foreach($line2 as $value){
echo $value." ";
fwrite($of,$value." ");
}
echo "<br>";
fwrite($of,"
");
}
fclose($of);