Foreach $wpdb->insert inserting blank rows

Trying to add rows from textarea to MySql database, but just last row inserting correctly all other rows inserting empty

$model = 'MacBook Pro';
$lines = explode("n", $textarea);

foreach ($lines as $model_number) {
      $rows_affected = $wpdb->insert($table_name, array('model'=>$model,   'model_number'=>$model_number)); 

var_dump ($model_number) returning:

 string(6) "A4348 " string(6) "A3412 " string(5) "A8495" 

MySql rows:

| 87 | MacBook Pro | A8495                            |

Source: wordpress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.