Update string.utils.php

This commit is contained in:
Namhyeon Go 2020-05-27 11:11:02 +09:00 committed by GitHub
parent 1d226d54d1
commit f215034928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);