<pre><code>function array_value_from_key($array,$key)
{
     return !empty($array[$key]) ? $array[$key] : null;
}
</code></pre>

<p>The reason I ask is because I have a class function that returns an array.</p>

<p>Instead of having to do</p>

<pre><code>$myArray = myClass::giveMeArray();
$myValue = $myArray[$myKey];
</code></pre>

<p>I'd like to do something along the lines of</p>

<pre><code>$myValue = array_value_from_key(myClass::giveMeArray(),$myKey);
</code></pre>

<p>When an object is returned, you can chain the object such as</p>

<pre><code>$myValue = myClass::giveMeObject()-&gt;aValue;
</code></pre>

<p>Voila, nice and clean..  not being able to find what seems to be a simple and trivial function is driving me crazy...</p>

<p>PS.. one more example of how I'd like to use such a function</p>

<pre><code>if(arrayKeyVal(aClass::giveMeArray(),$myKey)) {
    do_something();
}
</code></pre>

I haven't tried it, but:
```
```
$myValue = @$myArray[$myKey];
```
```
might work, though i honestly think you would be better off using
```
```
$myValue = (array_key_exists($myKey, $myArray)) ? $myArray[$myKey] : null;
```
```