I have csv values like this:
$csv_data = "test,this,thing
hi,there,this
is,cool,dude
have,fun";
I want to take an entire CSV string and read it into a multidemensional array so that I get:
array(
array(
'test' => 'hi',
'this' => 'there',
'thing' => 'this'
),
array(
'test' => 'is',
'this' => 'cool',
'thing' => 'dude'
),
array(
'test' => 'have',
'this' => 'fun',
'thing' => ''
)
);
I want an output like that, take note that the CSV value is dynamic.
Assuming every row in the CSV data has the same number of columns, this should work.
If lines have a variable number of columns (as in your example, where the last line has 2 columns instead of 3), use this loop instead: