add implode_when_necessary global function

This commit is contained in:
sunxyw 2022-04-04 00:10:42 +08:00
parent 4702aa1987
commit 8335cfed69
No known key found for this signature in database
GPG Key ID: CEA01A083E98C578

View File

@ -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;
}
/**
* 以下为废弃的函数,将于未来移除
*/