检查数组数据中的空数据(jquery或php)

I try to build An Automated Scoring System using Codeigniter 3.x And Jquery and have a difficult time finding the source.

Answer input method are multiple-choice and short answer or multi answer.

Like blow image

sample image

My HTML:

[CHECKBOX LIST]
<div class="btn-group" data-toggle="buttons">
    <label class="btn btn-lg btn-default">
        <input type="checkbox"  class="input_ans" name="<?=$t->idx?>"  value="1" />1
    </label>
    <label class="btn btn-lg btn-default">
        <input type="checkbox"  class="input_ans" name="<?=$t->idx?>"  value="2" />2
    </label>
    <label class="btn btn-lg btn-default">
        <input type="checkbox"  class="input_ans" name="<?=$t->idx?>"  value="3" />3
    </label>
    <label class="btn btn-lg btn-default">
        <input type="checkbox"  class="input_ans" name="<?=$t->idx?>"  value="4" />4
    </label>
    <label class="btn btn-lg btn-default">
        <input type="checkbox"  class="input_ans" name="<?=$t->idx?>"  value="5" />5
    </label>
</div>

[INPUT TEXT LIST}
<?php 
$tagArray = explode(',',$t->EAnswer); 
$arrayCount = count($tagArray);
?>
<?php
if ($arrayCount == 1) {
    echo '<input class="form-control input-lg input_ans1" name="'.$t->idx.'" type="text">';
} else {
    for ($i=0; $i < $arrayCount; $i++) { 
        $calc_col = 12 / $arrayCount;
        echo "<div class='col-md-$calc_col col-xs-$calc_col' style='padding:5px;'>";
        echo '<input class="form-control input-lg input_ans1" name="'.$t->idx.'" type="text">';
        echo "</div>";
    }
}
?>

CHECKBOX LIST is multiple-choice Answer, INPUT TEXT LIST is short answer or multi-answer.

My Javascript:

<script>
$(".submit_answer").click(function(event){
    event.preventDefault();
    var searchIDs = $(".input_ans:checked").map(function(){
        return this.name+':'+ this.value;
    }).toArray();

    var searchIDs1 = $(".input_ans1").map(function(){
        return this.name+':'+this.value;
    }).toArray();

    bootbox.confirm("ARE YOU SUBMIT TEST?", function(result) {
        if(result) {
            var merge_sort = $.merge( $.merge([],searchIDs), searchIDs1);
            var array_data = merge_sort.toString();
            $.ajaxSettings.traditional = true;
            $.ajax({ 
                    type : "POST",
                    data : { "data" : array_data },
                    dataType: "html",
                    url : '/CONTROLLER_NAME/AAA?>',
                    success : function(msg) {
                        console.log(msg)

                        if () {
                            // error
                        } else {                        
                            /// success
                        }
                    }
            })  
        } 
    });
})

</script>

My PHP:

<?php
$data = $this->input->post('data');
$tags = explode(',',$data);

natsort($tags);

$new= [];

foreach($tags as $v) {
    $temp = explode(':', $v);
    $new[$temp[0]][] = $temp[1];
}
foreach($new as $k => $v) {
    $new[$k] = $k . ':' . implode(',', $v);
}

foreach ($new as $key) {
    $Num = strrev(strstr(strrev($key) , ':'));
    $Text = strstr($key , ':');

    if (validate data) {
        }
    else {
            //do something
        }
}

My question is How do I check validate Empty Data in Jquery or PHP? Like below image:

sample image2

I want to do check if:

$Text = strstr($key , ':');

is Empty then alert to:

alert($Num."nth data is Empty")

or

alert(please input data)

In php

 if(empty($text)){ echo "please input data"; // your code here
    }