diff options
author | Christian Schneider | 2024-11-22 16:04:18 +0100 |
---|---|---|
committer | Christian Schneider | 2024-11-22 16:04:18 +0100 |
commit | 8b913996bbeff055585beb6b4307b5b33082c919 (patch) | |
tree | 66fc0f92207939c2e3c79c05ba6e25a5c8e28624 | |
parent | 86278151d49dc090047ba659ca3a646d36b7a2b6 (diff) | |
download | itools-8b913996bbeff055585beb6b4307b5b33082c919.tar.gz itools-8b913996bbeff055585beb6b4307b5b33082c919.tar.bz2 itools-8b913996bbeff055585beb6b4307b5b33082c919.zip |
Add (as of PHP 8.4) mandatory str_getcsv escape parameter but use newly recommended empty string to disable it instead of old default of backslash
-rw-r--r-- | it_pipe.class | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/it_pipe.class b/it_pipe.class index 413a7b5..30e89e5 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -208,7 +208,7 @@ function csv($p = []) $counts = count_chars($this->lines[0]); $splitchar = $counts[ord("\t")] ? "\t" : ($counts[ord(";")] > $counts[ord(",")] ? ";" : ","); $csvhead = it::replace(['^\x{FEFF}' => ''], array_shift($this->lines)); # it::replace removes utf8 byte order mark - $schema = $p['forceschema'] ? explode(",", $p['forceschema']) : str_getcsv(trim($csvhead, "#\n "), $splitchar, '"'); # should function_exists('str_getcsv') + $schema = $p['forceschema'] ? explode(",", $p['forceschema']) : str_getcsv(trim($csvhead, "#\n "), $splitchar, '"', ''); # should function_exists('str_getcsv') foreach ($schema as $idx => $col) $schema[$idx] = it::replace(['^$' => "field$idx", '\W' => $p['fixcolnames'] ? "_" : '$0'], $col); @@ -218,7 +218,7 @@ function csv($p = []) foreach ($this->lines as $line) { - if (($cols = str_getcsv($line, $splitchar, '"')) && (count($schema) == count($cols) || $nullcols)) + if (($cols = str_getcsv($line, $splitchar, '"', '')) && (count($schema) == count($cols) || $nullcols)) $records[] = (object)array_combine($schema, $cols + $nullcols); else return (array)it::error((array)$p['it_error'] + ['title' => "csv column count mismatch: " . count($schema) . " in header vs " . count($cols) . " in row", 'body' => [$schema, $cols]]); |