Skip to content

Commit

Permalink
Add new methods for array key casting
Browse files Browse the repository at this point in the history
  • Loading branch information
ilbeygi committed Mar 5, 2024
1 parent 5050195 commit 348a637
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,4 +936,26 @@ public static function wrap($value)

return is_array($value) ? $value : [$value];
}

/**
* Convert all keys in the given associative array to lowercase.
*
* @param array $array The input array.
* @return array The array with all keys converted to lowercase.
*/
public static function lowercaseKeys(array $array): array
{
return array_change_key_case($array, CASE_LOWER);
}

/**
* Convert all keys in the given associative array to uppercase.
*
* @param array $array The input array.
* @return array The array with all keys converted to uppercase.
*/
public static function uppercaseKeys(array $array): array
{
return array_change_key_case($array, CASE_UPPER);
}
}

0 comments on commit 348a637

Please sign in to comment.