Your array should be such as to insert a new row after each value
Array ( [0] => Something1\n [1] => Something2\n [2] => Something3\n )
Performing this action:
file_put_contents($file, trim($final_result . "\n"), FILE_APPEND);
You insert a new line after the full array
As @NielsKeurentjes said you need to see in which plataform you are writing the file:
\ r = CR (carriage return) // Used as a newline character in Unix
\ n = LF (Line Feed) // Used as the new line character in Mac OS
\ r \ n = CR + LF // Used as a new line character in Windows
Emilio gort
source share