删除数组中具有相同值的项目

See my following array, i need to be able to remove the items that have the same values (e.g. Primary, Secondary etc.) Is there a way of doing this to the existing array via php or is it easier to do this before items are inserted into the array?

I've seen the array_unique function but not sure if I can use this seen as it's a multi dimensional array?

Array
(
    [0] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 19
            [value] => Primary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 0
            [usageCount] => 
        )

    [1] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 20
            [value] => Secondary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 1
            [usageCount] => 
        )

    [2] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 20
            [value] => Secondary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 1
            [usageCount] => 
        )

    [3] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 21
            [value] => Groups & Families
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 2
            [usageCount] => 
        )

    [4] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 19
            [value] => Primary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 0
            [usageCount] => 
        )

    [5] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 20
            [value] => Secondary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 1
            [usageCount] => 
        )

    [6] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 21
            [value] => Groups & Families
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 2
            [usageCount] => 
        )

    [7] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 22
            [value] => Adults
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 3
            [usageCount] => 
        )

    [8] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 19
            [value] => Primary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 0
            [usageCount] => 
        )

    [9] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 20
            [value] => Secondary
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 1
            [usageCount] => 
        )

    [10] => SelectAttributeTypeOption Object
        (
            [error] => 
            [ID] => 21
            [value] => Groups & Families
            [th] => TextHelper Object
                (
                )

            [displayOrder] => 2
            [usageCount] => 
        )
)

Take a look at array_filter function:

array_filter( $array, function( $elem ) use ( $value ) {   
  return $elem['value'] !== $value; 
});

Hope it helps.

Try this:

$new = array_reduce(
    $old,
    function ($result, $item) {
        if (!in_array($item, $result)) {
            $result[] = $item;
        }
        return $result;
    }
);

But if these objects are fetched from DB, you're better off filtering your result set beforehand with GROUP BY id or whatever unique record identifier you have, as Finciuc Sergiu suggested.

I hope this helps

foreach($array as $row) {
    if(!isset($output[$row['value']])) {
        $output[$row['value']] = $row;
    }
}

//reset array keys if you want //$output = array_values($output)