0

約 200,000 行のログ ファイルがあります。各行の形式は次のとおりです。

AAA||BBB|C|DDD||

次に、次の解析ループを使用して値を解析します。

$fh = fopen($filename, 'r');
if($fh === FALSE) {
  return null;
}
$result = array();
while(!feof($fh)) {
  $line = fgets($fh);
  $tokens = explode('||', $line);
  $a = $tokens[0];
  list($b, $c, $d) = explode('|', $tokens[1]);
  // then I can get the values of AAA , BBB , C and DDD and put it into an array
  $result[$a] = array('a' => $a, 'b' => $b, 'c' => $c, 'd' => $d);
}

$result[$a]必要なものはすべて含まれていますが、解析時間は約 2.1 秒です。解析速度を下げるにはどうすればよいですか?

4

3 に答える 3