Careful with this method. It can lose information.
The keys will not be changed, thus possibly overwrite each other.
TODO: check if it can be replace by Hash::flatten() or Utility::flatten().
/** * UtilityTest::testArrayFlattenAndPreserveKeys() * * @covers ::arrayFlatten * @return void */ public function testArrayFlattenAndPreserveKeys() { $array = [0 => 1, 1 => ['c' => ['d' => ['g', 'h' => true]]], 2 => 'm']; $res = Utility::arrayFlatten($array, true); $expected = [0 => 'g', 'h' => true, 2 => 'm']; $this->assertSame($expected, $res); }