Similar to array_shift but on the keys of the array
like array_shift() only for keys and not values
public static arrayShiftKeys ( array &$array ) : string | ||
$array | array | keyValuePairs |
return | string | key |
/** * UtilityTest::testArrayShiftKeys() * * @covers ::arrayShiftKeys * @return void */ public function testArrayShiftKeys() { $array = ['a' => 1, 'b' => ['c' => ['d' => ['f' => 'g', 'h' => true]]], 'k' => 'm']; $res = Utility::arrayShiftKeys($array); $expected = 'a'; $this->assertSame($expected, $res); $expected = ['b' => ['c' => ['d' => ['f' => 'g', 'h' => true]]], 'k' => 'm']; $this->assertSame($expected, $array); }