public static function uniqueBy(array $elements, $selector)
    {
        return array_values(self::toMap($elements, Functions::extractExpression($selector)));
    }
public static function uniqueBy(array $elements, $selector)
    {
        return array_values(self::toMap($elements, Functions::extractExpression($selector)));
    }
public static function uniqueBy ( array $ elements , $ selector ) { return array_values ( self :: toMap ( $ elements , Functions :: extractExpression ( $ selector ) ) ) ; }
Removes duplicate values from an array. It uses the given expression to extract value that is compared.

Example:
<code>
$a = new stdClass();
$a->name = 'bob';

$b = new stdClass();
$b->name = 'bob';

$array = [$a, $b];
$result = Arrays::uniqueBy($array, 'name');
</code>
Result:
<code>
Array
(
[0] => $b
)
</code>

@param array $elements
@param $selector
@return array
@throws Exception
Removes duplicate values from an array . It uses the given expression to extract value that is compared .