Skip to content

Commit 8885c4e

Browse files
authored
Merge pull request #2713 from PHPOffice/Filter-return-result-array-indexes
Bugfix to returned column indexes for FILTER() by row
2 parents 11edcc9 + 2ab582a commit 8885c4e

File tree

2 files changed

+3
-3
lines changed
  • src/PhpSpreadsheet/Calculation/LookupRef
  • tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef

2 files changed

+3
-3
lines changed

src/PhpSpreadsheet/Calculation/LookupRef/Filter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function filter($lookupArray, $matchArray, $ifEmpty = null)
2929
return $ifEmpty ?? ExcelError::CALC();
3030
}
3131

32-
return array_values($result);
32+
return array_values(array_map('array_values', $result));
3333
}
3434

3535
private static function enumerateArrayKeys(array $sortArray): array

tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/FilterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testFilterByRow(): void
1515
['East', 'Tom', 'Apple', 6830],
1616
['East', 'Fritz', 'Apple', 4394],
1717
['South', 'Sal', 'Apple', 1310],
18-
['South', 'Hector', 'Apple', 98144],
18+
['South', 'Hector', 'Apple', 8144],
1919
];
2020
$result = Filter::filter($this->sampleDataForRow(), $criteria);
2121
self::assertSame($expectedResult, $result);
@@ -70,7 +70,7 @@ protected function sampleDataForRow(): array
7070
['East', 'Fritz', 'Banana', 6274],
7171
['West', 'Sravan', 'Pear', 4894],
7272
['North', 'Xi', 'Grape', 7580],
73-
['South', 'Hector', 'Apple', 98144],
73+
['South', 'Hector', 'Apple', 8144],
7474
];
7575
}
7676

0 commit comments

Comments
 (0)