現在、次のようなスクリプトがあります。
<?php
$pattern = '/(?<=\=\s)([0-9]+)(?=\s\=)/';
$total = 0;
$matches;
$handle = @fopen("log.txt", "r");
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
if(preg_match($pattern, $buffer, $matches))
{
$total += intval($matches[0]);
}
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
echo $total;
?>
問題は、変数 $total が新しい数値で頻繁に更新されることです。ユーザーが更新しなくても、ページの番号が自動的に更新されるようにします。見た目からして AJAX を使う必要があるのではないかと思いますが、私の AJAX は非常に弱いです。誰でも私を助けることができますか?ありがとう!