php getting unique values of a multidimensional array

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-03-14T13:14:26Z Indexed on 2010/03/14 13:15 UTC
Read the original article Hit count: 671

Filed under:
|

I have an array like this:

$a = array ( 
    0 => array ( 'value' => 'America', ), 
    1 => array ( 'value' => 'England', ),  
    2 => array ( 'value' => 'Australia', ), 
    3 => array ( 'value' => 'America', ), 
    4 => array ( 'value' => 'England', ), 
    5 => array ( 'value' => 'Canada', ), 
)

How can I remove the duplicate values so that I get this:

$a = array ( 
    0 => array ( 'value' => 'America', ), 
    1 => array ( 'value' => 'England', ),  
    2 => array ( 'value' => 'Australia', ), 
    4 => array ( 'value' => 'Canada', ), 
)

I tried using array_unique, but that doesn't work due to this array being multidimensional, I think.

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays