PHP function to extract data from deep within a multidimensional array

Extracts data from deep within a multidimensional array.

function getArrayValue(array $arrData, array $arrKeys = array()){
	$retVal = $arrData;
	foreach($arrKeys as $key){
		if(isset($retVal[$key])){
			$retVal = $retVal[$key];
		} else {
			return array( NULL );
		}
	}
	return $retVal;
}

 

By Karl Payne

Comments

There are no comments, don't be shy, somebody has to be first.

Leave a comment