Skip to content

Commit 89823ab

Browse files
committed
mention constructor arguments. note Flatten::unflatten and it's relation to Flatten::unflattenToArray
1 parent cfed182 commit 89823ab

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff 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
/*
3647
assert($flattened == [
@@ -41,7 +52,6 @@ assert($flattened == [
4152

4253
assert($unflattened == $multiArray);
4354
*/
44-
4555
```
4656

4757
**Example 2**
@@ -192,7 +202,6 @@ assert($flattened == [
192202

193203
assert($unflattened == $examples);
194204
*/
195-
196205
```
197206
Top level numeric (integer) keys will also be returned into an array assigned to the passed prefix.
198207

0 commit comments

Comments
 (0)