działa super, ale...
<?php
(
(
[shipping] => 400
)
(
[shipping] => 800
)
(
[shipping] => 1600
)
(
[shipping] => 400
)
)
?>
czegoś takiego nie potrafię

przepuścić poźniej przez pętlę, żeby uzyskać w rezultacie, przypuśćmy:
<?php
echo $result['shipping']; ?>
dla każdego 'ownerid'.
Byłbyś tak dobry i napisał pętlę?
mam już rozwiązanie, byc może komuś się przyda:
<?php
//Your initial array
(
'ownerid' => 100073,
'shipping' => 10
),
(
'ownerid' => 107266,
'shipping' => 20
),
(
'ownerid' => 107266,
'shipping' => 35
),
(
'ownerid' => 100073,
'shipping' => 40
),
(
'ownerid' => 123456,
'shipping' => 80
)
);
//Create an array that will keep the ownerid as key and the sum of shippings as value
foreach ($shops as $data) {
$inter_shops [$data['ownerid']] += $data['shipping'];
}
//You can check if this way is enough
//Create the array anyway you want (the way you want it in this case)
$count = 0;
foreach ($inter_shops as $ownerid => $shipping) {
$final_shops[$count]['ownerid'] = $ownerid;
$final_shops[$count]['shipping'] = $shipping;
$count++;
}
//See the result
?>