From 6a54a6a5098f1761a167ee2163847df8f38a1ed0 Mon Sep 17 00:00:00 2001 From: Fonata Date: Fri, 2 Apr 2021 21:06:15 +0200 Subject: [PATCH] Move parsing of .php files (sic!) to _rfile for easier refactoring Note that this arcane code comes from v0.2.0 beta: https://github.com/parsecsv/parsecsv-for-php/commit/5f0e6b03d430dfc7a7fb4e8002e15874f020c038 --- src/Csv.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Csv.php b/src/Csv.php index 56cc974..e69cbc6 100644 --- a/src/Csv.php +++ b/src/Csv.php @@ -936,10 +936,6 @@ class Csv { $this->file = $file; } - if (preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ms', $data, $strip)) { - $data = ltrim($strip[1]); - } - if (strpos($data, "\xef\xbb\xbf") === 0) { // strip off BOM (UTF-8) $data = substr($data, 3); @@ -1225,6 +1221,12 @@ class Csv { if ($data === false) { return false; } + + if (preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ms', $data, $strip)) { + // Return section behind closing tags. + $data = ltrim($strip[1]); + } + return rtrim($data, "\r\n"); }