foreach ($arr as $a1){
$getd=explode(",",$a1);
$b1=$getd[0];
}
In above code, if that $getd[0]
is empty i want to go to next record.
We can use an if statement to only cause something to happen if $getd[0]
is not empty.
foreach ($arr as $a1) {
$getd=explode(",",$a1);
if (!empty($getd[0])) {
$b1=$getd[0];
}
}
Alternatively, we can use the continue
keyword to skip to the next iteration if $getd[0]
is empty.
foreach ($arr as $a1) {
$getd=explode(",",$a1);
if (empty($getd[0])) {
continue;
}
$b1=$getd[0];
}