php foreach if last item
$numItems = count($arr);
$i = 0;
foreach($arr as $key=>$value) {
if(++$i === $numItems) {
echo "last index!";
}
}
php foreach if last item
$numItems = count($arr);
$i = 0;
foreach($arr as $key=>$value) {
if(++$i === $numItems) {
echo "last index!";
}
}
if first php
$x = 1;
$length = count($data);
foreach($data as $value){
echo"
<button class='btn";
if($x === 1){
echo " first";
}
else if($x === $length){
echo " last";
}
$x++;
echo"
'>$value->services_name</button>
";
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us