From fc7d9c235cf845e687095d4f30d32eca4c12bc4a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 22:23:28 -0700 Subject: minor code optimisation --- include/text.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 13c4bb819..bc44f22f3 100644 --- a/include/text.php +++ b/include/text.php @@ -2324,6 +2324,23 @@ function stringify_array_elms(&$arr, $escape = false) { $arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'"; } + +/** + * @brief Similar to stringify_array_elms but returns a string. If $escape is true, dbesc() each element before adding quotes. + * + * @param array $arr + * @param boolean $escape (optional) default false + * @return string + */ +function stringify_array($arr, $escape = false) { + if($arr) { + stringify_array_elms($arr); + return(implode(',',$arr)); + } + return EMPTY_STR; +} + + /** * @brief Indents a flat JSON string to make it more human-readable. * -- cgit v1.2.3