I have an array:
$result = array(
'a' => 15,
'b' => 25,
'a' => 10,
'c' => 6,
'k' => 10
);
I need the sum of same key values.
i.e. output like:
$result = array(
'a' => 25,
'b' => 25,
'c' => 6,
'k' => 10
);
I have an array:
$result = array(
'a' => 15,
'b' => 25,
'a' => 10,
'c' => 6,
'k' => 10
);
I need the sum of same key values.
i.e. output like:
$result = array(
'a' => 25,
'b' => 25,
'c' => 6,
'k' => 10
);
This is impossible, in an associative array the keys are unique by definition. It wouldn't be quite associative otherwise.