I want to convert a csv file with data like this in a multidimensional array.
1;name1;date1
2;name2;date2
The name of the file is vervangingen.csv. And I want the array to be like this:
Array (
[0] => Array
(
[0] => 1
[1] => name1
[2] => date1
)
[1] => Array
(
[0] => 2
[1] => name2
[2] => date1
)
)
Currently I have this:
$csv = array();
$file = fopen('vervangingen.csv', 'r');
while (($result = fgetcsv($file)) !== false)
{
$csv[] = $result;
}
fclose($file);
echo '<pre>';
print_r($csv);
echo '</pre>';
But this makes the array look like this. I know there exists something like explode, but I don't know how exactly I would use it here. Could anyone help me maybe?
Array
(
[0] => Array
(
[0] => 1;name1;date1
)
[1] => Array
(
[0] => 2;name2;date2
)
)