I'm a beginner in php. My code le a csv file and saves it in an array. The problem is that I can not access the columns. I'm using php 5.3.3. Does anyone know how I get the line and the column?
This is my role:
function readCsv($fileName)
{
if(!file_exists($fileName) || !is_readable($fileName)) return false;
$header = null;
$data = array();
$lines = file($fileName);
foreach($lines as $line) {
$values = str_getcsv($line, ',', '\');
if(!$header) $header = $values;
else $data[] = array_combine($header, $values);
}
return $data;
}
And this is my exit:
Array
(
[Section #] =>
[Q #] => 1
[Q Type] => MAT
[Q Title] =>
[Q Text] => Please rank your 6 preferred sites for your practicum:
[Bonus?] =>
[Difficulty] =>
[Answer] => Boniface (STB)
[Answer Match] => Rank 2
[# Responses] => 0
)
Array
(
[Section #] =>
[Q #] => 1
[Q Type] => MAT
[Q Title] =>
[Q Text] => Please rank your 6 preferred sites for your practicum:
[Bonus?] =>
[Difficulty] =>
[Answer] => Boniface (STB)
[Answer Match] => Rank 2
[# Responses] => 0
)
Array
(
[Section #] =>
[Q #] => 1
[Q Type] => MAT
[Q Title] =>
[Q Text] => Please rank your 6 preferred sites for your practicum:
[Bonus?] =>
[Difficulty] =>
[Answer] => Boniface (STB)
[Answer Match] => Rank 2
[# Responses] => 0
)