如何在php explode数组中处理空值?

I am trying to create a table with specific <th> values, my data varies like this:

Field Name, Field Value;Field Name, Field Value;Field Name, Field Value;

I am using two explode in a foreach loop like this.

$custom_fields = $row{'custom_fields'};

$fields = explode(";", $custom_fields);

foreach ($fields as $field) {
    $cf = explode(',', $field);

    echo "<td>".$cf[1]."</td>";
}

This outputs the data as needed, except the amount of values in the array vary (there are a total of 34 possible value). How do I get the empty rows to show no value, or leave them empty?

What I am looking for:

<table class="">
    <thead>
        <tr>
            <th nowrap>Choose your plan</th>
            <th nowrap>Month</th>
            <th nowrap>Day</th>
            <th nowrap>Year</th>
            <th nowrap>Street Address</th>
            <th nowrap>City</th>
            <th nowrap>State</th>
            <th nowrap>Zip</th>
            <th nowrap>Phone</th>
            <th nowrap>Alternate Phone</th>
            <th nowrap>Email Address</th>
            <th nowrap>Provider ID #</th>
            <th nowrap>I have read and understand the Terms and Conditions</th>
            <th nowrap>Total Plan Members</th>
            <th nowrap>Family Member 2 First Name</th>
            <th nowrap>Family Member 2 Last Name</th>
            <th nowrap>Family Member 3 First Name</th>
            <th nowrap>Family Member 3 Last Name</th>
            <th nowrap>Family Member 4 First Name</th>
            <th nowrap>Family Member 4 Last Name</th>
            <th nowrap>Family Member 5 First Name</th>
            <th nowrap>Family Member 5 Last Name</th>
            <th nowrap>Family Member 6 First Name</th>
            <th nowrap>Family Member 6 Last Name</th>
            <th nowrap>Family Member 7 First Name</th>
            <th nowrap>Family Member 7 Last Name</th>
            <th nowrap>Family Member 8 First Name</th>
            <th nowrap>Family Member 8 Last Name</th>
            <th nowrap>Family Member 9 First Name</th>
            <th nowrap>Family Member 9 Last Name</th>
            <th nowrap>Family Member 10 First Name</th>
            <th nowrap>Family Member 10 Last Name</th>
            <th nowrap>Date of Birth (dd/mm/yyyy)</th>
            <th nowrap>Billing same as Shipping</th>
        </tr>
    </thead>
    <tbody>
    <tr>
    $custom_fields = $row{'custom_fields'};

    $fields = explode(";", $custom_fields);

    foreach ($fields as $field) {
        $cf = explode(',', $field);

        echo "<td>".$cf[1]."</td>";
    }
    </tr>
</tbody>
</table>

Try this:

$custom_fields = $row{'custom_fields'};
$fields = explode(";", $custom_fields);
foreach ($fields as $field) {
  $cf = explode(',', $field);
  if(count($cf)== 2)
  {
     echo "<td>".$cf[1]."</td>";
  }
  else
  {
     echo "<td>No Value</td>";
  }
}