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

enter image description here

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

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -