From 79229c2e9191cb4ab8fd1925d7913e8d2b9ee9d8 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 9 Jun 2025 11:13:55 +0800 Subject: [PATCH] * [refac,done,0.1h] To move the position of the arrayUnion function on the mobile. --- framework/base/helper.class.php | 28 ++++++++++++++++++++++++++++ framework/helper.class.php | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/framework/base/helper.class.php b/framework/base/helper.class.php index f657339bb6..0fe094343f 100644 --- a/framework/base/helper.class.php +++ b/framework/base/helper.class.php @@ -1473,3 +1473,31 @@ if(!interface_exists('JsonSerializable')) return $data; } } + +/** + * 把一个或多个数组附加到第一个数组,用于替换数组 + 运算符。 + * Append one or more arrays to the first array, used to replace the array + operator. + * + * reference: https://www.php.net/manual/en/language.operators.array.php. + * + * @param array ...$args + * @return array + */ +function arrayUnion(...$args): array +{ + $args = array_filter($args, function($arg){return is_array($arg);}); + + $count = count($args); + if($count == 0) return []; + if($count == 1) return reset($args); + + $result = array_shift($args); + foreach($args as $arg) + { + foreach($arg as $key => $value) + { + if(!isset($result[$key])) $result[$key] = $value; + } + } + return $result; +} diff --git a/framework/helper.class.php b/framework/helper.class.php index d29557aaf1..3bfb7dacd6 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -869,31 +869,3 @@ function addPrefixToField(&$data, $fieldName, $suffix = '. ') $key++; } } - -/** - * 把一个或多个数组附加到第一个数组,用于替换数组 + 运算符。 - * Append one or more arrays to the first array, used to replace the array + operator. - * - * reference: https://www.php.net/manual/en/language.operators.array.php. - * - * @param array ...$args - * @return array - */ -function arrayUnion(...$args): array -{ - $args = array_filter($args, function($arg){return is_array($arg);}); - - $count = count($args); - if($count == 0) return []; - if($count == 1) return reset($args); - - $result = array_shift($args); - foreach($args as $arg) - { - foreach($arg as $key => $value) - { - if(!isset($result[$key])) $result[$key] = $value; - } - } - return $result; -}