diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-11-20 20:39:43 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-11-20 20:39:43 -0500 |
commit | f119cbd6be467b3832a4543045980dd0f1936275 (patch) | |
tree | de15caae64fbf5318ce67000356af4e47b531ec6 /app | |
parent | 4c3e519fa98de57ce9aa78f808b62f462aeaa690 (diff) |
Make CSV export compatible with PHP 5.3
Diffstat (limited to 'app')
-rw-r--r-- | app/Core/Csv.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/Core/Csv.php b/app/Core/Csv.php index bec400ed..28c1997b 100644 --- a/app/Core/Csv.php +++ b/app/Core/Csv.php @@ -93,8 +93,7 @@ class Csv { if (! empty($value)) { $value = trim(strtolower($value)); - return $value === '1' || $value{0} - === 't' ? 1 : 0; + return $value === '1' || $value{0} === 't' ? 1 : 0; } return 0; @@ -164,10 +163,14 @@ class Csv */ public function write($filename, array $rows) { - $file = new SplFileObject($filename, 'w'); + $fp = fopen($filename, 'w'); - foreach ($rows as $row) { - $file->fputcsv($row, $this->delimiter, $this->enclosure); + if (is_resource($fp)) { + foreach ($rows as $row) { + fputcsv($fp, $row, $this->delimiter, $this->enclosure); + } + + fclose($fp); } return $this; |