How to avoid the undefined offset in this code snippet?

Hi. Hoping someone can explain this to me please.

$quantity = $_POST['quantity'];
          echo "<pre> -- quantity -- ";
          print_r($quantity);
          echo "</pre>";

This returns:
-- quantity --Array
(
[0] =>
[1] =>
[2] =>
[3] => 2
[4] =>
[5] =>
[6] =>
)

$selectitem = $_POST['selectitem'];
      echo "<pre> -- selectitem -- ";
      print_r($selectitem);
      echo "</pre>";

This returns:
-- selectitem --Array
(
[0] =>
[1] =>
[2] =>
[3] => ABC123 - Plain wood
[4] =>
[5] =>
[6] =>
)

$linedetail=array_combine($quantity, $selectitem);
          echo "<pre> -- linedetail -- ";
          print_r($linedetail);
          echo "</pre>";

This returns:
-- linedetail --Array
(
[] =>
[2] => ABC123 - Plain wood
)

Which then in turn causes a warning notice in the following:

foreach ($linedetail as $key => $keyvalue){
                $detail = explode(' - ',$keyvalue);
                echo "<pre> -- detail -- ";
            print_r($detail);
            echo "</pre>";
                    $code = trim($detail[0]);
                    $item = $detail[1];
            }

This returns:
-- detail --Array
(
[0] =>
)

Warning: Undefined array key 1 in ... etc.

-- detail --Array
(
[0] => ABC123
[1] => Plain wood
)

So my question is why is a blank element being created in
-- linedetail --Array
(
[] =>
[2] => ABC123 - Plain wood
)
and how can I avoid it from happening?