我創建了一個小腳本,用於打開文本文檔,每次用戶打開特定頁面時都會增加一個數字,並將新數字寫入文檔的下一行。我希望腳本能夠讀取文檔的最後一行並增加該數字。目前,它繼續查看第一行並增加輸入的第一個數字。PHP fopen腳本讀取線
function job_number_script(){
$job_data = "";
$user_info = $_SESSION['user_info'];
$user_id = $user_info['user']['id'];
$job_id = "";
//Initialize the return
$job_number_page = ("job_setup.txt");
$job_number = file($job_number_page);
$work = explode(",",$job_number[0]);
$work[0]++;
$job_id = $work[0]++;
$work2 = array($job_id, $user_id);
$works = implode(",",$work2);
$fp = fopen($job_number_page, "a+");
fputs($fp, "$works\n");
fclose($fp);
$job_data = $job_id;
return $job_data;
}
我實際上不得不編輯$ job_number,但是這個工作以及謝謝! – PlatiNUM 2012-02-15 14:34:38