Welcome Guest, Not a member yet? Register   Sign In
Re-arranging array of array
#1

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
Reply


Messages In This Thread
Re-arranging array of array - by ciadvantage - 03-10-2018, 09:58 AM
RE: Re-arranging array of array - by chisler - 03-11-2018, 03:59 PM
RE: Re-arranging array of array - by ciadvantage - 03-12-2018, 08:40 PM
RE: Re-arranging array of array - by chisler - 03-13-2018, 09:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB