【发布时间】:2017-09-20 19:27:50
【问题描述】:
我有一个问题,我无法在 for 循环中从数组中获取值,但我可以在 while 循环中访问它。
我似乎无法在网上找到答案,因此非常感谢您的帮助。
while ($pos = strpos($logTxt, $char, $pos))
{
$t++;
$pos += strlen($char);
$positions[$t] = $pos;
}
for($i = 0; $i < sizeof($positions); $i++)
{
$beginLine = $lastEndLine;
$endLine = $positions[2];
$textToEcho = substr($logTxt,$beginLine,$endLine);
$lastEndLine = $endLine;
}
【问题讨论】:
-
在 for 循环中总是需要
$positions[2]吗?就目前而言,我根本看不到 for 循环的原因
标签: php arrays for-loop while-loop