Skip to content

Commit

Permalink
fix: ArrayHelper remove method
Browse files Browse the repository at this point in the history
  • Loading branch information
deluxetom committed Jan 29, 2024
1 parent 839db0c commit 61d1477
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Core/Helper/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ public static function without(array $array, ...$keys): array
*/
public static function remove(array $array, ...$keys): array
{
// Create a copy of the array to avoid modifying the original array
$newArray = $array;
$newArray = [];

// Iterate over the keys and remove them from the new array
foreach ($keys as $key) {
unset($newArray[$key]);
$newArray[$key] = $array[$key] ?? null;

if (!empty($array[$key])) {
unset($array[$key]);
}
}

return $newArray;
Expand Down

0 comments on commit 61d1477

Please sign in to comment.