Example:
$array = array('1' => array('2' => array('3' => 'value')));
$value = Arrays::getNestedValue($array, array('1', '2', '3'));
Result:
value
public function get($keys) { if (!isset($_SESSION)) { return null; } return Arrays::getNestedValue($_SESSION, $keys); }
public static function labels($key = '') { $labels = self::loadLabels(); $explodedKey = explode('.', $key); return $key ? Arrays::getNestedValue($labels, $explodedKey) : $labels; }
public function translate($key, $params = array()) { $explodedKey = explode('.', $key); $translation = Arrays::getNestedValue($this->_labels, $explodedKey) ?: $key; return $this->localize(Strings::sprintAssoc($translation, $params)); }
public function getValue($args) { return Arrays::getNestedValue($this->_config, $args); }
/** * @test */ public function shouldReturnEmptyArrayWhenNotFoundInNestedValue() { //given $array = array('1' => array('2' => array('3' => 'value'))); //when $value = Arrays::getNestedValue($array, array('1', '2', '3', '4')); //then $this->assertNull($value); }