* [refac,done,0.1h] To move the position of the arrayUnion function on the mobile.

This commit is contained in:
tianshujie
2025-06-09 11:13:55 +08:00
parent 57da842e06
commit 79229c2e91
2 changed files with 28 additions and 28 deletions
+28
View File
@@ -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;
}
-28
View File
@@ -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;
}