Javascript php。。。使用文本文件将记录插入(追加)分号表?

Javascript php。。。使用文本文件将记录插入(追加)分号表?,javascript,php,html,Javascript,Php,Html,我正在使用一个文本文件,里面有一个分号表。。。我已经学会了如何获取数据。特别抓住我需要的任何专栏 <?php $statfile=$_GET['scd']; if ($statfile=='') { $statfile="/et3mach/status.txt"; } $temps = array(); $brdhover = array(); if (($handle = fopen($statfile, "r")) !== FALSE) { while (($da

我正在使用一个文本文件,里面有一个分号表。。。我已经学会了如何获取数据。特别抓住我需要的任何专栏

<?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);
}

?>
代替
fopen()
fwrite()
fclose()
用户可以使用带有
FILE\u APPEND
标志的包装函数,如下所示

file_put_contents($file, $content, FILE_APPEND);

我会试试这个。。。阅读更多关于这个函数的内容。。。你肯定回答了我的问题,谢谢!!!:)@Malanno当有人回答你的问题时,你应该将该问题标记为已接受,或者至少对其进行投票。是的,我应该这样做,我很抱歉我正在重写代码,并且正在着手解决它……)
file_put_contents($file, $content, FILE_APPEND);