Permalink
Browse files

course/import/groups: MDL-20876 Fix split() call and remove redundant…

… escaping.
  • Loading branch information...
1 parent caf0021 commit d44bdfb0686f01d4bf1006a55cb22622a0a4b16b @doctorlard doctorlard committed Jul 20, 2010
Showing with 5 additions and 7 deletions.
  1. +5 −7 course/import/groups/index.php
@@ -72,15 +72,13 @@
} else {
$csv_encode = '/\&\#44/';
if (isset($CFG->CSV_DELIMITER)) {
- $csv_delimiter = '\\' . $CFG->CSV_DELIMITER;
- $csv_delimiter2 = $CFG->CSV_DELIMITER;
+ $csv_delimiter = $CFG->CSV_DELIMITER;
if (isset($CFG->CSV_ENCODE)) {
$csv_encode = '/\&\#' . $CFG->CSV_ENCODE . '/';
}
} else {
- $csv_delimiter = "\,";
- $csv_delimiter2 = ",";
+ $csv_delimiter = ",";
}
// prepare temp file
@@ -107,7 +105,7 @@
"hidepicture" => 1);
// --- get header (field names) ---
- $header = split($csv_delimiter, fgets($fp,1024));
+ $header = explode($csv_delimiter, fgets($fp,1024));
// check for valid field names
foreach ($header as $i => $h) {
$h = trim($h); $header[$i] = $h; // remove whitespace
@@ -136,10 +134,10 @@
}
//Note: commas within a field should be encoded as &#44 (for comma separated csv files)
//Note: semicolon within a field should be encoded as &#59 (for semicolon separated csv files)
- $line = split($csv_delimiter, fgets($fp,1024));
+ $line = explode($csv_delimiter, fgets($fp,1024));
foreach ($line as $key => $value) {
//decode encoded commas
- $record[$header[$key]] = preg_replace($csv_encode,$csv_delimiter2,trim($value));
+ $record[$header[$key]] = preg_replace($csv_encode,$csv_delimiter,trim($value));
}
if ($record[$header[0]]) {
// add a new group to the database

0 comments on commit d44bdfb

Please sign in to comment.