I am trying to count the total sum of values using array_combine. I have the duplicate key also, for example i have the array of emailid and array of product price.
$data1 = array("[email protected]","[email protected]","[email protected]");
and $data2 = array("100","200","300");
Now in $data1 i have two duplicate values as [email protected]
I am trying to use array_combine() It ignore the duplicate values and add the new one
I get this result as
[email protected] => 300;
[email protected] => 200;
But i want the result should be
[email protected] => (400)100+300;
[email protected] => 200;
Not sure how to get this result with array_combine Is something any alternatives to achieve this ?
Any Suggestion would be great.
array_combinesimply won't help you here. It's trivial if you write a manual loop though.