Skip to content

Commit d355f35

Browse files
committed
fixed bug, no separator when flatting array with first value by index "0"
1 parent 2b165a6 commit d355f35

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Flatten.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private function flattenGenerator($var, $prefix)
155155
}
156156
}
157157

158-
$prefix .= (empty($prefix) ? '' : $this->separator);
158+
$prefix .= ($prefix === '' ? '' : $this->separator);
159159
foreach ($var as $key => $value) {
160160
foreach ($this->flattenGenerator($value, $prefix . $key) as $k => $v) {
161161
yield $k => $v;

test/FlattenTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function arraysProvider()
5858
{
5959
return [
6060
[ [ ], [ ] ],
61+
[ [ [ 'a' => 1 ], [ 'b' => 2] ], ['0.a' => 1, '1.b' => 2] ],
6162
[ [ 0 ], [ '0' => 0 ] ],
6263
[ [ 1, 2 ], [ '0' => 1, '1' => 2 ] ],
6364
[

0 commit comments

Comments
 (0)