Voting

: zero plus seven?
(Example: nine)

The Note You're Voting On

amri [ at t] dhstudio dot eu
15 years ago
I searched how to show only the de-duplicate elements from array, but failed.
Here is my solution:

<?php
function arrayUniqueElements($array)
{
return
array_unique(array_diff_assoc($array1,array_unique($array1)));
};
?>

Example:
<?php
$arr1
= array('foo', 'bar', 'xyzzy', '&', 'xyzzy',
'baz', 'bat', '|', 'xyzzy', 'plugh',
'xyzzy', 'foobar', '|', 'plonk', 'xyzzy',
'apples', '&', 'xyzzy', 'oranges', 'xyzzy',
'pears','foobar');

$result=arrayUniqueElements($arr1);
print_r($result);exit;
?>

Output:

Array
(
[4] => xyzzy
[12] => |
[16] => &
[21] => foobar
)

<< Back to user notes page

To Top