Reversing the PHP file() function

arrays, file, newline, php

Solution

Use `file_put_contents()` and `implode()`:

file_put_contents('/your/file.php', implode(PHP_EOL, $fileArray));

Problem

I converted a .php file to an array using the file() function. Now I modified the array and I want to put all it contents back to the file (keeping line endings)... Someone can tell me if there is a function that does the opposite of file()? I want to bypass the annoying "array to string conversion" way... Thanks in advance!

Original source