Wednesday, October 14, 2009

Duplicate entries in Array

function dupli_val($array)
{
if ( !is_array($array) ) {
return false;
}

$repeat = array();
foreach ( $array as $key => $val ) {
end($array);
$k = key($array);
$v = current($array);

while ( $k !== $key )
{
if ( $v === $val )
{
$repeat[$key] = $v;
}
$v = prev($array);
$k = key($array);
}
}

return $repeat;
}

No comments:

Post a Comment