Search key by value in multi dimensional array
<p>Using PHP's website as a reference I'm trying to search for a key of the known value in associative array:</p>

<p><a href="http://php.net/manual/en/function.array-search.php" rel="nofollow">http://php.net/manual/en/function.array-search.php</a></p>

<p>The following code always returns 1, but suppose to return 120:</p>

<pre><code>$location_key = array_search(1, array_column($locations, 'main'));
</code></pre>

<p>print_r($locations):</p>

<pre><code>Array
(
    [120] =&gt; Array
        (
            [clientid] =&gt; 122103
            [name] =&gt; HQ
            [address] =&gt; 2013 BENSON GARDEN BLVD
            [address2] =&gt; 
            [city] =&gt; OMAHA
            [state] =&gt; NE
            [zip] =&gt; 68134
            [country] =&gt; UNITED STATES
            [lat] =&gt; 00.000
            [lng] =&gt; -0.0000
            [taxrate] =&gt; 0
            [main] =&gt; 1
            [active] =&gt; 1
            [contactid] =&gt; 14
        )

    [122] =&gt; Array
        (
            [clientid] =&gt; 122103
            [name] =&gt; Branch
            [address] =&gt; 515E E 72ND ST
            [address2] =&gt; 
            [city] =&gt; NEW YORK
            [state] =&gt; NY
            [zip] =&gt; 10021
            [country] =&gt; UNITED STATES
            [lat] =&gt; 40.766705
            [lng] =&gt; -73.952965
            [taxrate] =&gt; 0
            [main] =&gt; 0
            [active] =&gt; 1
            [contactid] =&gt; 0
        )

)
</code></pre>

<p>Not sure why PHP's website is referencing the highest up voted "User Contributed Note" which doesn't work.</p>