0
我在裏面用分號表使用文本文件...我已經學會了如何獲取我的數據。具體搶我需要的任何列...php ...使用文本文件插入(追加)記錄到分號表中?
<?php
$statfile=$_GET['scd'];
if ($statfile=='')
{
$statfile="/et3mach/status.txt";
}
$temps = array();
$brdhover = array();
if (($handle = fopen($statfile, "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE)
{
if(substr(trim($data[0]), 0, 3) == 'BRD')
{
$board = trim($data[0]); // get the index (e.g "BRD 0") & strip leading or trailing blanks
$temp = trim($data[10]); // the tempreture data is the 10th field; trim that also, to be safe.
$temps[ $board ] = $temp;
$brdhover[ $board ] = $data[11]; // Field 11 is the "hover" text; don't trim that for now...
}
}
fclose($handle);
}
?>
但插入比較困難,所有我能想出的插入一條記錄到一個文本文件中...
<?php
$companyfile = "data/company.txt";
if (isset($_POST['company']))
{
$newData = nl2br(htmlspecialchars($_POST['company']));
$handle = fopen($companyfile, "w");
fwrite($handle, $newData);
fclose($handle);
}
// ----------------------------
if (file_exists($companyfile)) {
$companyData = file_get_contents($companyfile);
}
如何合併這兩個函數,所以我可以插入和附加郵件使用HTML表單?在這種情況下,我有一列有一列的分號表。任何幫助表示讚賞。
我會嘗試這...更多閱讀了關於該功能......你肯定回答我的問題,謝謝! :) – Malanno
@Malanno當有人回答你的問題時,你應該將問題標記爲*接受*或至少使其滿意。 – samayo
是的,我應該,我很抱歉,我正在重寫代碼,並且正在接近它.. :) – Malanno