diff --git a/src/Filter.php b/src/Filter.php index 9fd9c35..872412c 100644 --- a/src/Filter.php +++ b/src/Filter.php @@ -134,7 +134,9 @@ protected function filterArrayWithGlobalChain(array $data) $data = $this->filterValueWithGlobalChain($value, $key, $data); } - return array_filter($data); + return array_filter($data, function ($value) { + return $value || is_numeric($value); + }); } /** diff --git a/tests/FilterTest.php b/tests/FilterTest.php index 2507cf5..5099905 100644 --- a/tests/FilterTest.php +++ b/tests/FilterTest.php @@ -322,8 +322,18 @@ public function testRemoveNullOnAllMultidimensionalValues() ], 'test2' => null, ], + 'test6' => '0', + 'test7' => '0.0', ]); - $this->assertEquals(['test2' => 'test', 'test4' => 'test'], $result); + $this->assertEquals( + [ + 'test2' => 'test', + 'test4' => 'test', + 'test6' => '0', + 'test7' => '0.0' + ], + $result + ); } }