title: Invalid argument supplied for foreach()
body: <p>How can fix error <code>Message: Invalid argument supplied for foreach() - Line Number: 28</code> in following <code>foreach</code> ?</p>
  
  <pre><code>&lt;?php
  $mileage = array();
  $mileage_input = $this-&gt;input-&gt;post('mileage');
  foreach ($mileage_input as $idx =&gt; $name) {  //Line 28
      $mileage[] = array(
          'mileage' =&gt; $mileage_input[$idx]
      );
  }
  $data = array(
      'mileage' =&gt; json_encode($mileage),
      'customer_number' =&gt; $customer_number,
      'name' =&gt; $this-&gt;input-&gt;post('name')
  );
  $this-&gt;db-&gt;insert('customer', $data);
  ?&gt;
  </code></pre>