Skip to content


Laravel collection multidimensional arrays recursive

Laravel1 min read

When I use the laravel collection recursive I find it’s very nice but it’s only supported the arrays of one dimensional. I need to do it support multidimensional arrays now.

It’s a good idea to use the macroable extending collection, here is a solution. Register the macro in boot method within your app\Providers\AppServiceProvider.php:


Thanks for @brunogaspar provides the idea!