OK、私はうんざりです。php foreachは最初の繰り返しの後で停止します
私はそれに660個のレコードを持つ多元配列を持っています。私がforeachを走らせるとき、パスごとに一つのレコードを得るべきですが、私が得るのは最初のレコードだけです。私はエラー報告をアップし、何も戻って来ず、私はforeach内のメモリを割り当てていません(テーブルの内容を出力するだけです)。
$totCount = count($funnel);
echo "We found $totCount log entries<br><br>\n"; // 66x records!
echo "<table border='1'>\n";
echo "<tr><th>Visitor</th><th>Date</th><th>Time/Page ---></th></tr>\n";
$nCount = 0; // number of records
$nRec = 0;
$ip = ""; // current records ip address
$date = ""; // current records date
$time = ""; // current records time
$file = ""; // file that was viewed
foreach($funnel as $page);
{
// process each record
$nRec++;
// if the ip's are different, this is a new visitor
if(strcmp($page['ip'], $ip) != 0)
{
if($nCount > 0) // only end a row if its not the first one
echo "</tr>\n"; // close out this row
// update the variables
$ip = $page['ip']; // save the new visitors ip
$date = $page['date']; // save the new visitors date
$time = $page['time']; // save the new visitors time
$file = $page['path']; // save the new visitors file viewed
echo "<tr>\n"; // start a new row
echo "<td>$ip</td><td>$date</td>\n";
echo "<td>$time<br>$file</td>";
$nCount++;
}
else
{
// not a new visit
$time = $page['time']; // what time was this page viewed?
$file = $page['path']; // where did they go next?
echo "<td>$time<br>$file</td>";
}
}
echo "</table>";
echo "<br>Processing Complete. $nCount visitors of $totCount/$nRec";
上記の行は、私は66Xの1人の訪問者があったと言うとNRECは、foreachのは1度に実行示す1:
コードは次のようになります。
助けていただけたら幸いです!
? – LeleDumbo
はい、$ funnelが本当に複数のエントリを持つ配列であることを保証する必要があります。 – chaoskreator