1. Go to this page and download the library: Download wrossmann/array_uunique library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wrossmann / array_uunique example snippets
if( ! function_exists('array_uunique') ) {
/**
* Remove duplicate elements from an array using a user-defined Reductor
* @param array $array
* @param callable $reductor Reduces a single array element to a simple type for strict equivalence checking.
*/
function array_uunique(array $array, callable $reductor) {
$seen = [];
return array_filter(
$array,
function($a)use(&$seen, $reductor){
$val = $reductor($a);
if( ! in_array($val, $seen, true) ) {
$seen[] = $val;
return true;
} else {
return false;
}
}
);
}
}