📅  最后修改于: 2022-03-11 14:54:21.838000             🧑  作者: Mango
$count = 0;
$len = count($array);
foreach ($array as $item) {
if ($count == 0) {
// first
} else if ($count == $len - 1) {
// last
}
// increment
$count++;
}