Example:
$array = array('1' => array('2' => array('3' => 'value')));
$value = Arrays::hasNestedKey($array, array('1', '2', '3'));
Result:
true
Example with null values:
$array = array('1' => array('2' => array('3' => null)));
$value = Arrays::hasNestedKey($array, array('1', '2', '3'), Arrays::TREAT_NULL_AS_VALUE);
Result:
true
public function has($keys) { return Arrays::hasNestedKey($_SESSION, Arrays::toArray($keys)); }
/** * @test */ public function hasNestedKeyShouldReturnFalseWhenKeyIsNullAndNullIsNotValue() { //given $array = array('1' => array('2' => array('3' => null))); //when $value = Arrays::hasNestedKey($array, array('1', '2', '3')); //then $this->assertFalse($value); }