title: Php array unique subarray based on a value
body: <p>I am in a situation to make an array unique by the subarray index.Please refer this code and help me to solve this.</p>
  
  <pre><code>    $user=Array(
         [1]=&gt;Array(
                   username =&gt; Sujith,
                   email=&gt;someone@example.com,
                   [address] =&gt; Array(
                      [address_id] =&gt; 1227
                      [city] =&gt; Ayoor
                      [state] =&gt; Kerala
                      [Country] =&gt; India
                   )
        )
       [2]=&gt;Array(
           username =&gt; Ajith,
           email=&gt;someone2@example.com,
           [address] =&gt; Array(
              [address_id] =&gt; 1227
              [city] =&gt; Ayoor
              [state] =&gt; Kerala
              [Country] =&gt; India
          )
       )
       [3]=&gt;Array(
           username =&gt; Akhil,
           email=&gt;someone3@example.com,
           [address] =&gt; Array(
              [address_id] =&gt; 1228
              [city] =&gt; Kollam
              [state] =&gt; Kerala
              [Country] =&gt; India
          )
  
      )
   )
  </code></pre>
  
  <p>I want to make it unique by the address.address_id.So the resulting array should be</p>
  
  <pre><code>    $user=Array(
             [1]=&gt;Array(
                       username =&gt; Sujith,
                       email=&gt;someone@example.com,
                       [address] =&gt; Array(
                          [address_id] =&gt; 1227
                          [city] =&gt; Ayoor
                          [state] =&gt; Kerala
                          [Country] =&gt; India
                       )
            )
           [3]=&gt;Array(
               username =&gt; Akhil,
               email=&gt;someone3@example.com,
               [address] =&gt; Array(
                  [address_id] =&gt; 1228
                  [city] =&gt; Kollam
                  [state] =&gt; Kerala
                  [Country] =&gt; India
              )
  
          )
       )
  </code></pre>
  
  <p>I mean ,1 user per address..Please help me to solve this..</p>