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!
Use file_put_contents()
and implode()
:
file_put_contents('/your/file.php', implode(PHP_EOL, $fileArray));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With