Function to search associative array keys
<p>I am writing a shopping cart session handler class and I find myself repeating this certain chunk of code which searches a multidimensional associative array for a value match.</p>

<pre><code>foreach($_SESSION['cart'] as $k =&gt; $v){

    if($v['productID'] == $productID){
        $key = $k;
        $this-&gt;found = true;
    }
}
</code></pre>

<p>I am repeating this when trying to match different values in the array.
Would there be an easy to to create a method whereby I pass the key to search and the value. (Sounds simple now I read that back but for some reason have had no luck)</p>
