File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
src/Illuminate/Collections Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -112,13 +112,19 @@ public static function dot($array, $prepend = '')
112
112
{
113
113
$ results = [];
114
114
115
- foreach ($ array as $ key => $ value ) {
116
- if (is_array ($ value ) && ! empty ($ value )) {
117
- $ results = array_merge ($ results , static ::dot ($ value , $ prepend .$ key .'. ' ));
118
- } else {
119
- $ results [$ prepend .$ key ] = $ value ;
115
+ $ flatten = function ($ data , $ prefix ) use (&$ results , &$ flatten ): void {
116
+ foreach ($ data as $ key => $ value ) {
117
+ $ newKey = $ prefix .$ key ;
118
+
119
+ if (is_array ($ value ) && ! empty ($ value )) {
120
+ $ flatten ($ value , $ newKey .'. ' );
121
+ } else {
122
+ $ results [$ newKey ] = $ value ;
123
+ }
120
124
}
121
- }
125
+ };
126
+
127
+ $ flatten ($ array , $ prepend );
122
128
123
129
return $ results ;
124
130
}
You can’t perform that action at this time.
0 commit comments