I know there is array_unique
function, but I want to remove duplicates. Is there a built-in function or do I have to roll my own.
Example input:
You can use
$singleOccurences = array_keys(
array_filter(
array_count_values(
array('banana', 'mango', 'banana', 'mango', 'apple' )
),
function($val) {
return $val === 1;
}
)
)
See