function write_log($str,$status,$data_array) //傳入資料夾名 想寫近的狀態 資料
{
$textname = $str.date("Ymd").".txt"; //檔名 filename
$URL = "log/".$str."/"; //路徑 Path
if(!is_dir($URL)) // 路徑中的$str 資料夾是否存在 Folder exists in the path
mkdir($URL,0700);
$URL .= $textname; //完整路徑與檔名 The full path and filename
$time = $str.$status.":".date("H:i:s"); //時間 Time
$writ_tmp = '';
foreach ($data_array as $key => $value) //將陣列資料讀出 To read array data
{
$writ_tmp .= ",".$key."=".$value;
}
$write_data = $time.$writ_tmp."\n";
$fileopen = fopen($URL, "a+");
fseek($fileopen, 0);
fwrite($fileopen,$write_data); //寫資料進去 write data
fclose($fileopen);
}
沒有留言:
張貼留言