diff --git a/src/common/lists/Arr.php b/src/common/lists/Arr.php index 33d22279..4e3d588e 100644 --- a/src/common/lists/Arr.php +++ b/src/common/lists/Arr.php @@ -177,6 +177,36 @@ public static function doForEach(array $array, callable $function): void } } + /** + * Copy array to remove any existing references + * @param mixed[] $array + * @return mixed[] + */ + public static function copy(array $array): array + { + $result = []; + foreach ($array as $key => $value) { + $result[$key] = $value; + } + + return $result; + } + + /** + * Copy array to remove any existing references. Drop keys + * @param mixed[] $array + * @return mixed[] + */ + public static function copyValues(array $array): array + { + $result = []; + foreach ($array as $value) { + $result[] = $value; + } + + return $result; + } + // queries --------------------------------------------------------------------------------------------------------- /**