重建数组多维

时间:2014-06-17 15:05:38

标签: php arrays multidimensional-array

对于一个项目,我正在尝试重建数据库返回的数组。填充图表需要此数据。

  array
0 => 
array
  'payment_method_stats_id' => string '1' (length=1)
  'payment_method_id' => string '92' (length=2)
  'country_id' => string '1' (length=1)
  'total' => string '2' (length=5)
  'timestamp' => string '2014-01-17 13:39:41' (length=19)
  'payment_methods_id' => string '92' (length=2)
  'definition' => string 'iDeal' (length=5)
  'month' => string 'January' (length=7)
1 => 
array
  'payment_method_stats_id' => string '49' (length=2)
  'payment_method_id' => string '92' (length=2)
  'country_id' => string '1' (length=1)
  'total' => string '2' (length=5)
  'timestamp' => string '2014-02-17 13:39:41' (length=19)
  'payment_methods_id' => string '92' (length=2)
  'definition' => string 'iDeal' (length=5)
  'month' => string 'February' (length=8)
2 => 
array
  'payment_method_stats_id' => string '97' (length=2)
  'payment_method_id' => string '92' (length=2)
  'country_id' => string '1' (length=1)
  'total' => string '2' (length=5)
  'timestamp' => string '2014-03-17 13:39:41' (length=19)
  'payment_methods_id' => string '92' (length=2)
  'definition' => string 'iDeal' (length=5)
  'month' => string 'March' (length=5)
3 => 
array
  'payment_method_stats_id' => string '97' (length=2)
  'payment_method_id' => string '92' (length=2)
  'country_id' => string '1' (length=1)
  'total' => string '2' (length=5)
  'timestamp' => string '2014-03-17 13:39:41' (length=19)
  'payment_methods_id' => string '92' (length=2)
  'definition' => string 'Paypal' (length=5)
  'month' => string 'January' (length=5)
4 => 
array
  'payment_method_stats_id' => string '97' (length=2)
  'payment_method_id' => string '92' (length=2)
  'country_id' => string '1' (length=1)
  'total' => string '2' (length=5)
  'timestamp' => string '2014-03-17 13:39:41' (length=19)
  'payment_methods_id' => string '92' (length=2)
  'definition' => string 'Visa' (length=5)
  'month' => string 'January' (length=5)

数据库返回一个包含付款方式和月份的数组。如此理想,只有不同的月份返回12次。

现在我需要这个数据用于图表,我想将此数组重建为此

'Januari'
  =>payment
   => values, values, values, values values,
  =>payment
   => values, values, values, values, values

我怎么能完成这个

0 个答案:

没有答案