From aadbe6c4c89b8203468348178f432f2236db66f8 Mon Sep 17 00:00:00 2001 From: Chaim Date: Wed, 5 Aug 2020 14:47:47 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=95=B0=E7=BB=84=E9=97=A8=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E7=BB=84=E5=88=A0=E9=99=A4=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ src/common.php | 2 +- src/facade/Arrays.php | 1 + src/helper/Arrays.php | 20 ++++++++++++++++++++ src/helper/Strings.php | 2 +- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eefcaf..2f8e961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v6.0.102 / 2020-08-05 +- 数组门面增加数组删除空格 + ## v6.0.101 / 2020-07-25 - 优化代码 diff --git a/src/common.php b/src/common.php index fe68d3a..1dcc225 100644 --- a/src/common.php +++ b/src/common.php @@ -26,7 +26,7 @@ use think\db\exception\DbException; /** * 定义当前版本 */ -const VERSION = '6.0.101'; +const VERSION = '6.0.102'; if (!function_exists('get_ip_info')) { /** diff --git a/src/facade/Arrays.php b/src/facade/Arrays.php index 4bcd09c..7df6eb7 100644 --- a/src/facade/Arrays.php +++ b/src/facade/Arrays.php @@ -36,6 +36,7 @@ use think\Facade; * @method static array split(array $array, $num = 5) 分隔数组 * @method static array unique(array $array) 多维数组去重 * @method static array sort(array $arrays, string $sort_key, $sort_order = SORT_ASC, $sort_type = SORT_NUMERIC) 二维数组根据某个键排序 + * @method static string trimArray(array $arr) 数组删除空格 */ class Arrays extends Facade { diff --git a/src/helper/Arrays.php b/src/helper/Arrays.php index c2e7542..455162e 100644 --- a/src/helper/Arrays.php +++ b/src/helper/Arrays.php @@ -119,4 +119,24 @@ class Arrays array_multisort($key_arrays, $sort_order, $sort_type, $arrays); return $arrays; } + + /** + * 数组删除空格 + * @param array $arr + * @return array + */ + public function trimArray(array $arr) + { + if (!is_array($arr)) { + return $arr; + } + foreach ($arr as $key => $value) { + if (is_array($value)) { + $arr[$key] = $this->TrimArray($value); + } else { + $arr[$key] = \DtApp\ThinkLibrary\facade\Strings::trimAll(trim($value)); + } + } + return $arr; + } } diff --git a/src/helper/Strings.php b/src/helper/Strings.php index 472212f..794d630 100644 --- a/src/helper/Strings.php +++ b/src/helper/Strings.php @@ -170,7 +170,7 @@ class Strings } /** - * 删除空格 + * 字符串删除空格 * @param $str * @return string|string[] */