Hi all,
I have this kind of array of example,
$data = array(
array('name'=>'Test 1 Corp', 'serviced'=>'Visual help', 'price'=>'100.00' , 'serviced_date'=>'01/01/2018'),
array('name'=>'Test 2 Corp', 'serviced'=>'Reading help', 'price'=>'50.00' , 'serviced_date'=>'01/2/2018'),
array('name'=>'Test 1 Corp', 'serviced'=>'Visual help', 'price'=>'100.00','serviced_date'=>'01/02/2018'),
array('name'=>'Test 3 Corp', 'serviced'=>'Visual help', 'price'=>'100.00', 'serviced_date'=>'01/10/2018'),
array('name'=>'Test 1 Corp', 'serviced'=>'Misc help', 'price'=>'50.00'),
//.... could be more
);
I need to reduce this array to this format like
$reduced = array(
'Test 1 Corp' =>array( 'Visual Help' =>2, 'Reading Help'=>1, 'Misc Help'=>1),
'Test 2 Corp' =>array( 'Visual Help' =>0, 'Reading Help'=>1, 'Misc Help'=>0),
'Test 3 Corp' =>array('Visual Help'=>1, 'Reading Help'=>0, 'Misc Help'=>0)
//... could be more
);
In fact reduced array is like a sum up of all kinds services that belong to each company.
Any help is appreciated!
Thanks
I have this kind of array of example,
$data = array(
array('name'=>'Test 1 Corp', 'serviced'=>'Visual help', 'price'=>'100.00' , 'serviced_date'=>'01/01/2018'),
array('name'=>'Test 2 Corp', 'serviced'=>'Reading help', 'price'=>'50.00' , 'serviced_date'=>'01/2/2018'),
array('name'=>'Test 1 Corp', 'serviced'=>'Visual help', 'price'=>'100.00','serviced_date'=>'01/02/2018'),
array('name'=>'Test 3 Corp', 'serviced'=>'Visual help', 'price'=>'100.00', 'serviced_date'=>'01/10/2018'),
array('name'=>'Test 1 Corp', 'serviced'=>'Misc help', 'price'=>'50.00'),
//.... could be more
);
I need to reduce this array to this format like
$reduced = array(
'Test 1 Corp' =>array( 'Visual Help' =>2, 'Reading Help'=>1, 'Misc Help'=>1),
'Test 2 Corp' =>array( 'Visual Help' =>0, 'Reading Help'=>1, 'Misc Help'=>0),
'Test 3 Corp' =>array('Visual Help'=>1, 'Reading Help'=>0, 'Misc Help'=>0)
//... could be more
);
In fact reduced array is like a sum up of all kinds services that belong to each company.
Any help is appreciated!
Thanks