function array_value_from_key($array,$key)
{
return !empty($array[$key]) ? $array[$key] : null;
}
The reason I ask is because I have a class function that returns an array.
Instead of having to do
$myArray = myClass::giveMeArray();
$myValue = $myArray[$myKey];
I'd like to do something along the lines of
$myValue = array_value_from_key(myClass::giveMeArray(),$myKey);
When an object is returned, you can chain the object such as
$myValue = myClass::giveMeObject()->aValue;
Voila, nice and clean.. not being able to find what seems to be a simple and trivial function is driving me crazy...
PS.. one more example of how I'd like to use such a function
if(arrayKeyVal(aClass::giveMeArray(),$myKey)) {
do_something();
}