From f850fdd7569f51017c82c7d4e72ea3a72104b1c4 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Tue, 24 Oct 2017 00:34:40 -0300 Subject: [PATCH] Update php-export-data.class.php add funciton global mb_str_replace(){ ... } and methd public function addRowToArray($allRows = array()){ ... } --- php-export-data.class.php | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/php-export-data.class.php b/php-export-data.class.php index d983cf7..e13d4d6 100755 --- a/php-export-data.class.php +++ b/php-export-data.class.php @@ -1,6 +1,26 @@ $search) { + $parts = mb_split(preg_quote($search), $subject); + $count += count($parts) - 1; + $subject = implode($replacements[$key], $parts); + } + } else { + // Call mb_str_replace for each subject in array, recursively + foreach ($subject as $key => $value) { + $subject[$key] = mb_str_replace($search, $replace, $value, $count); + } + } + return $subject; + } +} /** * ExportData is the base class for exporters to specific file formats. See other * classes below. @@ -43,6 +63,14 @@ public function addRow($row) { $this->write($this->generateRow($row)); } + public function addRowToArray($allRows = array()) { + if(is_array($allRows) && count($allRows)>=1){ + foreach ($allRows as $row){ + $this->write($this->generateRow($row)); + } + } + } + public function finalize() { $this->write($this->generateFooter()); @@ -104,7 +132,8 @@ function generateRow($row) { foreach ($row as $key => $value) { // Escape inner quotes and wrap all contents in new quotes. // Note that we are using \" to escape double quote not "" - $row[$key] = '"'. str_replace('"', '\"', $value) .'"'; + //$row[$key] = '"'. str_replace('"', '\"', $value) .'"'; + $row[$key] = '"'. mb_str_replace('"', '\"', $value) .'"'; } return implode("\t", $row) . "\n"; } @@ -124,7 +153,8 @@ function generateRow($row) { foreach ($row as $key => $value) { // Escape inner quotes and wrap all contents in new quotes. // Note that we are using \" to escape double quote not "" - $row[$key] = '"'. str_replace('"', '\"', $value) .'"'; + //$row[$key] = '"'. str_replace('"', '\"', $value) .'"'; + $row[$key] = '"'. mb_str_replace('"', '\"', $value) .'"'; } return implode(",", $row) . "\n"; } @@ -239,4 +269,4 @@ function sendHttpHeaders() { header("Content-Disposition: inline; filename=\"" . basename($this->filename) . "\""); } -} \ No newline at end of file +}