From 8335cfed69f6eae3cdc738755d630f2cd7f24061 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 4 Apr 2022 00:10:42 +0800 Subject: [PATCH] add implode_when_necessary global function --- src/ZM/global_functions.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ZM/global_functions.php b/src/ZM/global_functions.php index 296565b5..460768e8 100644 --- a/src/ZM/global_functions.php +++ b/src/ZM/global_functions.php @@ -626,6 +626,18 @@ function zm_internal_errcode($code): string return "[ErrCode:{$code}] "; } +/** + * 将可能为数组的参数转换为字符串 + * + * 如传入字符串则为原样返回 + * + * @param array|string $string_or_array + */ +function implode_when_necessary($string_or_array): string +{ + return is_array($string_or_array) ? implode(', ', $string_or_array) : $string_or_array; +} + /** * 以下为废弃的函数,将于未来移除 */