07-22-2008, 01:22 PM
|
#6 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I got it working:
PHP Code:
/** * Function file_intersperse_contents * Params $szFilename, $szInject * * Writes the text into the logfile. New text is always added in the beginning of logfile so that newest is always on top * Returns true or false **/ function file_intersperse_contents($szFilename, $szInject) { // Check if file exist if(file_exists($szFilename)) { // If file exist // Get the content $szContent = file_get_contents($szFilename); // Add the new text in the beginning $szInject = $szInject . $szContent; // Open the file and delete all text in it $szFile = fopen($szFilename, 'w+'); } else { // If file does not exist // Create file and open the file $szFile = fopen($szFilename, 'a+'); } // Write the text into it $put = fwrite($szFile, $szInject); if($put) { // If success, return true return true; } // If failure, return false return false; // Close the file fclose($szFile);
}
__________________
|
|
|
|