PHP array unique by column
<p>How to filter an array to give unique elements according to one or more columns. Example:</p>

<pre><code>array(
    array('name'=&gt;'toto', 'type'=&gt;'1', 'type2'=&gt; '2')
    array('name'=&gt;'tata', 'type'=&gt;'1', 'type2'=&gt; '3')
    array('name'=&gt;'titi', 'type'=&gt;'1', 'type2'=&gt; '2')
    array('name'=&gt;'tutu', 'type'=&gt;'2', 'type2'=&gt; '4')
    array('name'=&gt;'tete', 'type'=&gt;'3', 'type2'=&gt; '2')
)
</code></pre>

<p>If we choose type and type2 as the unique column. The result of the algorithm should gives</p>

<pre><code>array(
    array('name'=&gt;'toto', 'type'=&gt;'1', 'type2'=&gt; '2')
    array('name'=&gt;'tata', 'type'=&gt;'1', 'type2'=&gt; '3')
    array('name'=&gt;'tutu', 'type'=&gt;'2', 'type2'=&gt; '4')
    array('name'=&gt;'tete', 'type'=&gt;'3', 'type2'=&gt; '2')
)
</code></pre>

<p>I can think of an algorithm by hashing the type concatenate with type2, store in a table and using isset to find the existence. But I'm not sure that's the best algorithm.</p>
