//this question is about array_combine (php5)
$array1=array(1, 2, 1); //it has the same value as 1 will be used as key
$array2=array(1, 2, 3); //value 1 will be assign to key 1, and value 3 will be assigned to key 1 again and overwrite the previous value?
$array3=array_combine($array1, $array2);
print_r ($array3); //what will be $array3? i don't have php5 yet.
//will $array3 be Array ( [1] => 3 [2] => 2 )
//but if I want sum up the values of array 2, if the key from array 1 is the same.
//meaning, the value 1 and 3 will be added up and assigned to key 1 in the merge
//so I have to use the following function
for ($index=0; $index<count($array1); $index++)
{
$this_key=$array1[$index];
$this_value=$array2[$index];
$array4[$this_key]+=$this_value;
}
print_r ($array4) //the return is Array ( [1] => 4 [2] => 2 ), it is the array I want.
//is this the right way to achieve what I want from "combine" arrays? Thanks!