get index of array with condition
<p>I have this kind of array :</p>

<pre><code>$arrVar = array(
    0 =&gt; array(
        'val'=&gt; 9
    ),
    1 =&gt; array(
        'val'=&gt; 12,
    ),
    2 =&gt; array(
        'val'=&gt; 4
    ),
);
</code></pre>

<p>How do I make a function that returns the index of an array based on a variable $myVar?
For example :</p>

<p>if <code>$myVar = 4</code> the function will return <code>$arrVar['2']</code></p>

<p>if <code>$myVar = 8</code> the function will return <code>$arrVar['2']</code></p>

<p>if <code>$myVar = 10</code> the function will return <code>$arrVar['0']</code></p>

<p>This is my array</p>

<pre><code>$arrVar = array(
    0 =&gt; array(
        'qty'=&gt;9,
        'disc'=&gt; 0.15
    ),
    1 =&gt; array(
        'qty'=&gt;12,
        'disc'=&gt; 0.20
    ),
    2 =&gt; array(
        'qty'=&gt;4,
        'disc'=&gt; 0.10
    ),
);
</code></pre>

<ul>
<li>when customer A buy 4 products he will get disc 10%</li>
<li>or when customer A buy 8 products he will get disc 10%</li>
<li>or when customer A buy 10 products he will get disc 15%</li>
</ul>
