Mega Code Archive

 
Categories / Php / File Directory
 

File_put_contents( ) writes to a file with the equivalent of fopen( ), fwrite( ), and fclose( ) all in one function, just l

<?     $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"; ?>