&$key_value) { $key_value = api_to_system_encoding($key_value, $from_encoding); } } while (($row_tmp = api_fgetcsv($handle, null, ';')) !== false) { $row = array(); // Avoid empty lines in csv if (is_array($row_tmp) && count($row_tmp) > 0 && $row_tmp[0] != '') { if (!is_null($row_tmp[0])) { if ($csv_order == 'vertical') { foreach ($row_tmp as $index => $value) { $row[$keys[$index]] = api_to_system_encoding($value, $from_encoding); } } else { $first = null; $count = 1; foreach ($row_tmp as $index => $value) { if ($count == 1) { $first = $value; } else { $row[$first][] = api_to_system_encoding($value, $from_encoding); } $count++; } } $result[] = $row; } } } fclose($handle); return $result; } }