This is not a very efficient structure. Have you considered consolidating it in this form?
array
(
10 => 6,
11 => 2,
);
That would allow fast key lookup on ID.
TO consolidate your first array into that form, just do this:
$array2 = array();
foreach($array1 as $row)
{
if(isset($array2[$row['id']]))
$array2[$row['id']] += $row['value'];
else
$array2[$row['id']] = $row['value'];
}
Which would give you an array in the form of:
$array2 = array
(
10 => 6,
11 => 2,
);
If you really need it in your requested form, one more processing loop will get it there...
$array3 = array();
foreach($array2 as $id => $value)
{
$array3[] = array('id' => $id, 'value' => $value);
}
So, there you go!
And more compact:
$array2 = array();
foreach($array1 as $row)
$array2[$row['id']] = (isset($array2[$row['id']]) ? $array2[$row['id']] : 0) + $row['value'];
$array3 = array();
foreach($array2 as $id => $value)
$array3[] = array('id' => $id, 'value' => $value);