Find the last element of an array while using a foreach loop in PHP
$numItems = count($arr);
$i = 0;
foreach($arr as $key=>$value) {
if(++$i === $numItems) {
echo "last index!";
}
}
PDOStatement::rowCount
Syntax with "endforeach" used mostly in complex templates where easier to find "endforeach" than "}":
Classic syntax:
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。