Hey guys im trying to save the values into an textfile. I tried different ways and always when i open the textfile all the values are written in one line without space. I want to write each value in its own line here is what i have so far:
$filename = 'admin_liste.txt';
$string = '';
foreach($arr as $key => $val) {
$string .= "$val\n";
}
file_put_contents($filename, $string);
This writes everything like this in the textfile:
user1user2user3user4
But i want it like this:
- user1
- user2
- user3
- user4
Without the “●”
You are using the Linux newline character, you need to use the
\r\nfor windows.So your code will look like this:
However, PHP has a built in constant which will handle this dependant on the operating system you are running. So instead of using the above, you could simply use the following (no point if your website is always going to be on Windows though, but point to know):