PHP – Writing to a file with php


Reading and writing always come together. Thus, after presenting the way to read from a file, now it is time to be able to write:



Writing in PHP is not a challenge, the only tricky part is to know how to make a new line. 🙂

In my code, I am using the following –     $new_line = chr(13) . chr(10);

The rest is easy to understand and quite trivial:

Enjoy it!