file_put_contents() With Array ArgumentΒΆ

By Gina Peter Banyard

The second argument of file_put_contents() is typed as mixed. It may be a string, which is the most common case. It may be a stream, (aka, a resource), which pours a file into a file.

It also may be an array. PHP simply writes the elements of the array in the file, like an implode('', $array).

../_images/file_put_array.png