Q:

Splitting Array

I have an array of objects. 
What I need is to take each [name] of each object in put into another array, but I don't want duplicates.
How can I do it?
Array (
    [0] => ADOFetchObj Object
        (
            [name] => Team 1
            [att] => None
            [idGrupo] => 1
            [idModulo] => 4
            [ler] => 1
            [escrever] => 1
            [excluir] => 1
        )

    [1] => ADOFetchObj Object
        (
            [name] => Team 1
            [nomeModulo] => Aplicar Juros
            [idGrupo] => 1
            [idModulo] => 1006
            [ler] => 1
            [escrever] => 1
            [excluir] => 1
        )

    [2] => ADOFetchObj Object
        (
            [name] => Team 2
            [att] => None
            [idGrupo] => 1
            [idModulo] => 10
            [ler] => 1
            [escrever] => 1
            [excluir] => 1
        )

    [3] => ADOFetchObj Object
        (
            [name] => Team 2
            [att] => None
            [idGrupo] => 1
            [idModulo] => 1012
            [ler] => 1
            [escrever] => 1
            [excluir] => 1
        )
)

Thanks!

A:

You can do this:
$names = array();
foreach($arr as $list) {
    $names[$list->name] = true; // can be *any* arbitrary value
}
$names = array_keys($names);

This will work because by definition array keys have to be unique.

A:

array_unique(array_map(function($element) {
    return $element->name;
}, $my_array));

A:

There you go 
$res = array();

foreach($arr as $var)
{
    if(!in_array($var->name, $res))
    {
      $res[] = $var->name;
    }
}

