Voting

: min(eight, four)?
(Example: nine)

The Note You're Voting On

Victoire Nkolo at crinastudio.com
2 years ago
<?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;
}
}

<< Back to user notes page

To Top