You can check the variables empty or not with the help o for each loop. We will declare the variables into an array and we will check the result is empty or not with the help of empty function

<?php
$a = "a";
$b = "f";
$c = "d";
$d = "";

$var = array($a,$b,$c,$d);
$valid = true;

foreach($var as $element) {
 
 if(empty($element)){
     // echo "empty";
    $i++; 
    }
  else{
    echo $element;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *