mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
introduces new local variable that holds the data
This commit is contained in:
14
src/Csv.php
14
src/Csv.php
@@ -552,10 +552,12 @@ class Csv {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_detect_and_remove_sep_row_from_data($this->file_data);
|
$data = $this->file_data;
|
||||||
|
|
||||||
|
$this->_detect_and_remove_sep_row_from_data($data);
|
||||||
|
|
||||||
$pattern = sprintf('/("[^%s]*")|[^%s]*/i', $this->enclosure, $this->enclosure);
|
$pattern = sprintf('/("[^%s]*")|[^%s]*/i', $this->enclosure, $this->enclosure);
|
||||||
preg_match_all($pattern, $this->file_data, $matches);
|
preg_match_all($pattern, $data, $matches);
|
||||||
|
|
||||||
foreach ($matches[0] as $match) {
|
foreach ($matches[0] as $match) {
|
||||||
if (empty($match) || (strpos($match, $this->enclosure) === false)) {
|
if (empty($match) || (strpos($match, $this->enclosure) === false)) {
|
||||||
@@ -563,14 +565,14 @@ class Csv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$replace = str_replace(["\r", "\n"], '', $match);
|
$replace = str_replace(["\r", "\n"], '', $match);
|
||||||
$this->file_data = str_replace($match, $replace, $this->file_data);
|
$data = str_replace($match, $replace, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$headingRow = $this->heading ? 1 : 0;
|
$headingRow = $this->heading ? 1 : 0;
|
||||||
|
|
||||||
$count = substr_count($this->file_data, "\r")
|
$count = substr_count($data, "\r")
|
||||||
+ substr_count($this->file_data, "\n")
|
+ substr_count($data, "\n")
|
||||||
- substr_count($this->file_data, "\r\n")
|
- substr_count($data, "\r\n")
|
||||||
- $headingRow;
|
- $headingRow;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user