I have the following csv file:
"Id","Title","Body","Tags"
"101","this title","
\"">.</>"";
","c# asp.net excel table"
which I want to convert into an array as follows:
Array
(
[0] => Array
(
[0] => Id
[1] => Title
[2] => Body
[3] => Tags
)
[1] => Array
(
[0] => 101
[1] => this title
[2] => \"">.</>"";
[3] => c# asp.net excel table
)
)
My code is:
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
$data[$c] = strip_tags($data[$c]);
}
$result[$row] = $data;
$row++;
}
fclose($handle);
return $result;
My problem is I am getting the following array:
Array
(
[0] => Array
(
[0] => Id
[1] => Title
[2] => Body
[3] => Tags
)
[1] => Array
(
[0] => 101
[1] => this title
[2] =>
\">.</>"";
)
[2] => Array
(
[0] => ,c# asp.net excel table"
)
)
In general, how do I avoid detecting too many recors when there is potentially code inside the fields (it's a StackOverflow data dump so some text fields have all kinds of programming code).