I got like this CSV:
1|bla.jpg|nature
2| |earth
When I convert the CSV to array like this:
while (($line = fgetcsv($handle, 1000, ';')) !== FALSE)
{
$data[] = $line;
}
then I get follow array in $data
:
array(2) {
[0]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(7) "bla.jpg"
[2]=>
string(6) "nature"
}
[1]=>
array(1) {
[0]=>
string(163) "2"
}
}
But I need it like that:
array(2) {
[0]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(7) "bla.jpg"
[2]=>
string(6) "nature"
}
[1]=>
array(3) {
[0]=>
string(1) "2"
[1]=>
string(0) ""
[2]=>
string(5) "earth"
}
}
How can I keep parsing CSV when one field is empty?
Ignore it: I need to add some more text -.-