Skip to content

Commit ab77af1

Browse files
author
Alaa Sarhan
authored
Added example of numeric keys
1 parent 995f977 commit ab77af1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,27 @@ $uris = Flatten::flatten($api, '/', 'https://api.dummyhost.domain/');
8282
)
8383

8484
*/
85-
```
85+
```
86+
87+
Numeric arrays will be also flattened using the numeric keys.
88+
```php
89+
$nutrition = [
90+
'nutrition',
91+
'fruits' => [ 'oranges', 'apple', 'banana' ],
92+
'veggies' => ['lettuce', 'broccoli'],
93+
];
94+
95+
$nutrition = Flatten::flatten($nutrition, '-');
96+
97+
/* print_r($nutrition):
98+
Array
99+
(
100+
[0] => nutrition
101+
[fruits-0] => oranges
102+
[fruits-1] => apple
103+
[fruits-2] => banana
104+
[veggies-0] => lettuce
105+
[veggies-1] => broccoli
106+
)
107+
*/
108+
```

0 commit comments

Comments
 (0)