php - issue with csv file row value remove white space -
i'm importing data csv file database using php
$i = 0; while(($data = fgetcsv($handle, 1000, ",")) !== false) { if($i!=0) { if(trim($data[0])!=' ') { $branddata['brand'] = $data[0]; $branddata['create_date'] = date('y-m-d h:i:s'); print_r($branddata); die; $res = $this->mdl_brands->insertintobrand($branddata); } } $i++; } and csv file has following data
after brand name in 2 row have added more 1 blank space inserting entry database.
however have used trim function remove blank spaces not working.
please guide how avoid this.
as said it:
i have used trim function remove blank spaces
you removed them! don't have check 1 space, do:
if(trim($data[0]) != '') { //^^ see here
Comments
Post a Comment