I'm looping through the result sets of two stored procedures, getting results within one stored procedures based on fields within the other.
The two arrays containing the results sets are $customers and $subcustomers.
foreach($customers as $customer)
{
foreach($subcustomers as $subcustomer)
{
if($subcustomer['parent'] == $customer['id'])
{
if($customer['innumber'] == null && $subcustomer['innumber'] != null)
{
$chartInboundSub['name'] = $customer['name'];
$chartInboundSub['label'] = $subcustomer['innumber'];
$chartInboundSub['countInbound'] = $customer['count'];
$chartInboundSub['minsInbound'] = ceil($customer['duration'] / 60);
$chartInboundSub['customerid'] = $customer['id'];
array_push($out['chartInbound'], $chartInboundSub);
}
}
}
}
The current output of print_r($out['chartInbound']) is the below:
Array
(
[0] => Array
(
[countInbound] => 426
[minsInbound] => 340
[name] => Telekomm
[label] => 01-02
[customerid] => 6
)
[1] => Array
(
[countInbound] => 1
[minsInbound] => 2
[name] => Telekomm
[label] => 01-02
[customerid] => 6
)
[2] => Array
(
[countInbound] => 3
[minsInbound] => 21
[name] => Telekomm
[label] => 080
[customerid] => 6
)
[3] => Array
(
[countInbound] => 1920
[minsInbound] => 15766
[name] => Telekomm
[label] => 084
[customerid] => 6
)
[4] => Array
(
[countInbound] => 2332
[minsInbound] => 17521
[name] => Telekomm
[label] => 084
[customerid] => 6
)
...
)
The above results need to be grouped by name, label, customerid with countInbound and minsInbound summed, so :
The desired output should be:
Array
(
[0] => Array
(
[countInbound] => 427
[minsInbound] => 342
[name] => Telekomm
[label] => 01-02
[customerid] => 6
)
[1] => Array
(
[countInbound] => 3
[minsInbound] => 21
[name] => Telekomm
[label] => 080
[customerid] => 6
)
[2] => Array
(
[countInbound] => 4252
[minsInbound] => 33287
[name] => Telekomm
[label] => 084
[customerid] => 6
)
...
)
countInboundandminsInboundwhen name, label and customerid are the same?$customersand$subcustomersarrays which can be used to generate the desired result.