Assume I already have a text file which looks like:
sample.txt
This is line 1.
This is line 2.
This is line 3.
.
.
.
This is line n.
How can I append data from an array to the END of each line?
The following ONLY attaches to the line following the last line.
appendThese = {"append_1", "append_2", "append_3", ... , "append_n"};
foreach($appendThese as $a){
file_put_contents('sample.txt', $a, FILE_APPEND); //Want to append each array item to the end of each line
}
Desired Result:
This is line 1.append_1
This is line 2.append_2
This is line 3.append_3
.
.
.
This is line n.append_n