@@ -286,6 +286,7 @@ will return:
286286<a href =" #uasorted " >uasorted</a >
287287<a href =" #uksort " >uksort</a >
288288<a href =" #uksorted " >uksorted</a >
289+ <a href =" #unflatten " >unflatten</a >
289290<a href =" #union " >union</a >
290291<a href =" #unique " >unique</a >
291292<a href =" #unshift " >unshift</a >
@@ -498,6 +499,7 @@ will return:
498499* [ transpose()] ( #transpose ) : Exchanges rows and columns for a two dimensional map
499500* [ traverse()] ( #traverse ) : Traverses trees of nested items passing each item to the callback
500501* [ trim()] ( #trim ) : Removes the passed characters from the left/right of all strings
502+ * [ unflatten()] ( #unflatten ) : Unflattens the key path/value pairs into a multi-dimensional array
501503* [ walk()] ( #walk ) : Applies the given callback to all elements
502504* [ zip()] ( #zip ) : Merges the values of all arrays at the corresponding index
503505
@@ -6965,6 +6967,32 @@ Map::from( ['B' => 'a', 'a' => 'b'] )->uksorted( function( $keyA, $keyB ) {
69656967* [ uksort()] ( #uksort ) - Sorts the map elements by their keys using a callback
69666968
69676969
6970+ ### unflatten()
6971+
6972+ Unflattens the key path/value pairs into a multi-dimensional array.
6973+
6974+ ``` php
6975+ public function unflatten() : self
6976+ ```
6977+
6978+ * @return ** self< ; string,mixed> ; ** New map with multi-dimensional arrays
6979+
6980+ ** Examples:**
6981+
6982+ ``` php
6983+ Map::from( ['a/b/c' => 1, 'a/b/d' => 2, 'b/e' => 3] )->unflatten();
6984+ // ['a' => ['b' => ['c' => 1, 'd' => 2]], 'b' => ['e' => 3]]
6985+
6986+ Map::from( ['a.b.c' => 1, 'a.b.d' => 2, 'b.e' => 3] )->sep( '.' )->unflatten();
6987+ // ['a' => ['b' => ['c' => 1, 'd' => 2]], 'b' => ['e' => 3]]
6988+ ```
6989+
6990+ ** See also:**
6991+
6992+ * [ flat()] ( #flat ) - Flattens multi-dimensional elements without overwriting elements
6993+ * [ collapse()] ( #collapse ) - Collapses all sub-array elements recursively to a new map
6994+
6995+
69686996### union()
69696997
69706998Builds a union of the elements and the given elements without returning a new map.
0 commit comments