So I'm attempting to explode my string of csv rows into an array and I'm having a difficult time.
Let me lead you through the steps:
var_dump($line);
returns an string as this: :string 'TEST Test Test2 Test3
Now, when I have an .txt
file, and I call $arr = explode("\t", $line);
, the $arr
returns an array
array (size=15) 0 => string 'TEST ' (length=11) 1 => string 'Test' (length=4) 2 => string 'Test 2' (length=0) 3 => string 'Test 3' (length=6)
But if I have an .csv
file, and I attempt to explode it, I get left with an array string as such:
array (size=1)
0 => string 'TEST Test Test2 Test3'
I tried doing the following but I'm not having much luck: $test = str_getcsv($line, "\t", '', '');
- All the examples for str_getcsv
show it like this:
$str = "the,cat,in,the,hat";
$arr = str_getcsv($str);
print_r($arr);
But mine aren't comma separated, but instead all tabbed.
All help would be appreciated.