I have an array like
$a = array(
array('id'=>1, 'value'=>2),
array('id'=>2, 'value'=>3),
array('id'=>3, 'value'=>4),
array('id'=>1, 'value'=>5),
array('id'=>5, 'value'=>10),
array('id'=>2, 'value'=>6),
);
from this i want an array which don't have the repeating id wise keys value e.g
$a = array(
array('id'=>3, 'value'=>4),
array('id'=>1, 'value'=>5),
array('id'=>5, 'value'=>10),
array('id'=>2, 'value'=>6)
);
i tried the following one but unable to get final result.
$i=0;
foreach ($a as $key=>$value) {
// $arr[$i] = $value;
foreach ($a as $key1=>$value1) {
if(!empty(array_diff($value, $value1))) {
if( $value['id'] == $value1['id'] ) {
$arr[$i]=$value1;
}
else {
$arr[$i]=$value;
}
}
}
$i++;
}