<?php
//removes duplicated objetcs from an array according to the property given
class ArrayFilter
{
public static function dedupe_array_of_objets(array $array, string $property) : array
{
$i = 0;
$filteredArray = array();
$keyArray = array();
foreach($array as $item) {
if (!in_array($item->$property, $keyArray)) {
$keyArray[$i] = $item->$property;
$filteredArray[$i] = $item;
}
$i++;
}
return $filteredArray;
}
}