php – How to save the result to a txt file?

The file_put_contents command writes a string to a file. If this file does not already exist, it creates the file.

                while ($ data = mysql_fetch_array ($ querymail)) {
$ log = str_pad ($ data[0], 10, "0", STR_PAD_LEFT);
$ log1 = str_pad ($ data[1], 40, "", STR_PAD_RIGHT);

$ rows. = $ log. "". $ log1. " not";
}

file_put_contents (& # 39; file.txt & # 39 ;, $ lines);

If you just want to add a value to an already created file, you will need to use a third parameter with the value FILE_APPEND, as follows:

file_put_contents (& # 39; file.txt & # 39 ;, lines, FILE_APPEND);