Conditions | 6 |
Paths | 2 |
Total Lines | 30 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public function readCsv($filePath) |
||
13 | { |
||
14 | $csvArray = []; |
||
15 | if (file_exists($filePath)) { |
||
16 | $file = fopen($filePath, 'r'); |
||
17 | $columnNames = array(); |
||
18 | |||
19 | foreach (fgetcsv($file) as $columnName) { |
||
20 | $columnNames[] = utf8_encode($columnName); |
||
21 | } |
||
22 | |||
23 | while (($line = fgetcsv($file)) !== false) { |
||
24 | $row = array_combine($columnNames, $line); |
||
25 | |||
26 | foreach ($row as &$column) { |
||
27 | if ($column === '') { |
||
28 | $column = false; |
||
29 | } else { |
||
30 | $column = utf8_encode($column); |
||
31 | } |
||
32 | } |
||
33 | unset($column); |
||
34 | $csvArray[] = $row; |
||
35 | } |
||
36 | |||
37 | fclose($file); |
||
38 | } |
||
39 | |||
40 | return $csvArray; |
||
41 | } |
||
42 | } |
||
43 |