Skip to content

Instantly share code, notes, and snippets.

@habibillah
Created July 13, 2011 14:27
Show Gist options
  • Save habibillah/1080393 to your computer and use it in GitHub Desktop.
Save habibillah/1080393 to your computer and use it in GitHub Desktop.
very-very simple way to wite file in PHP
function writeDataTofile($data=null) {
$upload_path = APP . 'tmp' . DS . 'logs' . DS . 'trace.log';
$fp = fopen($upload_path,'w');
if (is_array($data)) {
foreach ($data as $key=>$value) {
fwrite($fp, $key . ": " . $value . "\n\r");
}
} else {
fwrite($fp, $key . ": " . $value . "\n\r");
}
fclose($fp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment