$location_name) { $location_headers .= ',"location_' . $location_name . '"'; } return $location_headers; } /** * Generates a list of attribute names as a string * * @return string Comma-separated list of attribute names */ function generate_attribute_headers($attribute_names) { $attribute_headers = ""; unset($attribute_names[-1]); foreach($attribute_names as $attribute_name) { $attribute_headers .= ',"attribute_' . $attribute_name . '"'; } return $attribute_headers; } /** * Read the contents of a given CSV formatted file into a two-dimensional array * * @param string $file_name Name of the file to read. * @return boolean|array[][] two-dimensional array with the file contents or FALSE on failure. */ function get_csv_file($file_name) { ini_set("auto_detect_line_endings", true); if(($csv_file = fopen($file_name,'r')) !== FALSE) { //Skip Byte-Order Mark fseek($csv_file, 3); while (($data = fgetcsv($csv_file)) !== FALSE) { $line_array[] = $data; } } else { return FALSE; } return $line_array; } ?>