File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,22 @@ $multiArray = [
2626 'hi' => [ 'de' => 'Hallo', 'es' => 'Hola' ]
2727];
2828
29+ /*
30+ Flatten::__construct(
31+ string $separator = '.',
32+ string $prefix = '',
33+ int $flags = 0
34+ )
35+ */
2936$flatten = new Flatten();
3037
3138$flattened = $flatten->flatten($multiArray);
3239
33- $unflattened = $flatten->unflatten($flattened);
40+
41+ // Flatten::unflattenToArray is provided for convinience. It internally
42+ // calls Flatten::unflatten and converts it's output, which is a recursive
43+ // generator structure, into a multi-dimensional array.
44+ $unflattened = $flatten->unflattenToArray($flattened);
3445
3546/*
3647assert($flattened == [
@@ -41,7 +52,6 @@ assert($flattened == [
4152
4253assert($unflattened == $multiArray);
4354*/
44-
4555```
4656
4757** Example 2**
@@ -192,7 +202,6 @@ assert($flattened == [
192202
193203assert($unflattened == $examples);
194204*/
195-
196205```
197206Top level numeric (integer) keys will also be returned into an array assigned to the passed prefix.
198207
You can’t perform that action at this time.
0 commit comments