file_put_contents( ) writes to a file with the equivalent of fopen( ), fwrite( ), and fclose( ) all in one function, just like file_get_contents( ).
<?
$filename = 'data.txt';
$myarray[ ] = "This is line one";
$myarray[ ] = "This is line two";
$myarray[ ] = "This is line three";
$mystring = implode("\n", $myarray);
$numbytes = file_put_contents($filename, $mystring);
print "$numbytes bytes written\n";
?>
Related examples in the same category