From f215034928c6497bb898647c125c3c992913b50f Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 27 May 2020 11:11:02 +0900 Subject: [PATCH] Update string.utils.php --- helper/string.utils.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helper/string.utils.php b/helper/string.utils.php index 03eceb7..1c1088a 100644 --- a/helper/string.utils.php +++ b/helper/string.utils.php @@ -293,6 +293,18 @@ if(!is_fn("get_floating_percentage")) { } } +// https://stackoverflow.com/questions/13108157 +if(!is_fn("get_csv_from_array")) { + function get_csv_from_array($data, $delimiter = ',', $enclosure = '"', $escape_char = "\\") { + $f = fopen('php://memory', 'r+'); + foreach ($data as $item) { + fputcsv($f, $item, $delimiter, $enclosure, $escape_char); + } + rewind($f); + return stream_get_contents($f); + } +} + if(!is_fn("eregi")) { function eregi($pattern, $subject, &$matches=NULL) { return preg_match(sprintf("/%s/i", $pattern), $subject, $matches);