Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] adds formatKeysWith method to Arr #52421

Closed

Conversation

smetzdev
Copy link

@smetzdev smetzdev commented Aug 7, 2024

Hey folks,

this PR adds makes it possible to format the key names of an associative Array with any given callable.

  $formatedArray = Arr::formatKeysWith(["hello_laravel" => true ], [Str::class, 'camel']); 
  // ["helloLaravel" => true ];

I've also added a third $depth parameter, which defaults to the maximum integer

Greetings from Germany,
Sascha

@smetzdev smetzdev force-pushed the 11.x_adds_formatkeyswith_to_arr branch from 1633942 to b45758a Compare August 7, 2024 20:26
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@taylorotwell
Copy link
Member

You can use mapWithKeys

@smetzdev smetzdev deleted the 11.x_adds_formatkeyswith_to_arr branch August 8, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants