Nirav Trivedi Nirav Trivedi - 3 years ago 219
PHP Question

how to create unique array from array

Array

[0] => Array
(
[a1] => 12
[v1] => 3100.00
[v2] => 186.00
[v3] => 186.00
)

[1] => Array
(
[a1] => 12
[v1] => 1200.00
[v2] => 72.00
[v3] => 72.00
)


i want to create new array from this array
which is look like this as given below it should give me '12' common and add other values

Array

[0] => Array
(
[a1] => 12
[v1] => 4300.00
[v2] => 258.00
[v3] => 258.00
)

Answer Source
Try This code ,
foreach($value as $i=>$v) {
    $temp[0]['a1'] = $v['a1'];
    $temp[0]['v1'] += $v['v1'];
    $temp[0]['v2'] += $v['v2'];
    $temp[0]['v3'] += $v['v3'];

}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download