romapad
10/20/2015 - 3:35 PM

downloads.php

<?php 

$downloads_new = array (
  0 => 
  array (
    'download_url' => '//localhost:3000/sound/?download_file=96&order=wc_order_5621768e2a401&email=user@example.com&key=8d2889aa17eeaeb79b6788ce254376bc',
    'download_id' => '8d2889aa17eeaeb79b6788ce254376bc',
    'product_id' => 96,
    'download_name' => 'Woo Album #4 &ndash; 15_Morgengry.mp3',
    'order_id' => 1505,
    'order_key' => 'wc_order_5621768e2a401',
    'downloads_remaining' => '',
    'access_expires' => NULL,
    'file' => 
    array (
      'name' => '15_Morgengry.mp3',
      'file' => 'http://127.0.0.1/sound/wp-content/uploads/woocommerce_uploads/2013/06/15_Morgengry.mp3',
    ),
    'product_cat_dw' => 'Preset Banks',
    'product_cat_id' => 84,
    'product_tag_dw' => 'Kontakt',
    'product_tag_id' => 87,
  ),
  1 => 
  array (
    'download_url' => '//localhost:3000/sound/?download_file=96&order=wc_order_5621768e2a401&email=user@example.com&key=139cf079dd3e1d1e44c9f57684e34b80',
    'download_id' => '139cf079dd3e1d1e44c9f57684e34b80',
    'product_id' => 96,
    'download_name' => 'Woo Album #4 &ndash; 11_Stein Og Bark.mp3',
    'order_id' => 1505,
    'order_key' => 'wc_order_5621768e2a401',
    'downloads_remaining' => '',
    'access_expires' => NULL,
    'file' => 
    array (
      'name' => '11_Stein Og Bark.mp3',
      'file' => 'http://127.0.0.1/sound/wp-content/uploads/woocommerce_uploads/2013/06/11_Stein-Og-Bark.mp3',
    ),
    'product_cat_dw' => 'Preset Banks',
    'product_cat_id' => 84,
    'product_tag_dw' => 'Kontakt',
    'product_tag_id' => 87,
  ),
  2 => 
  array (
    'download_url' => '//localhost:3000/sound/?download_file=99&order=wc_order_5621f22cd5077&email=user@example.com&key=21fcc6abbfbad8ae22c45ee5256f06f2',
    'download_id' => '21fcc6abbfbad8ae22c45ee5256f06f2',
    'product_id' => 99,
    'download_name' => 'Woo Single #2 &ndash; ithemes security',
    'order_id' => 1508,
    'order_key' => 'wc_order_5621f22cd5077',
    'downloads_remaining' => '',
    'access_expires' => NULL,
    'file' => 
    array (
      'name' => 'ithemes security',
      'file' => 'http://127.0.0.1/sound/wp-content/uploads/woocommerce_uploads/2013/06/ithemes-security-pro-1.18.5.zip',
    ),
    'product_cat_dw' => 'Drum Kits',
    'product_cat_id' => 80,
    'product_tag_dw' => 'massive',
    'product_tag_id' => 88,
  ),
  3 => 
  array (
    'download_url' => '//localhost:3000/sound/?download_file=93&order=wc_order_56233378102da&email=user@example.com&key=625f270808d61a0a3220288e765f5cb2',
    'download_id' => '625f270808d61a0a3220288e765f5cb2',
    'product_id' => 93,
    'download_name' => 'Woo Single #1 &ndash; 04 McBurney\'s Jig.wma',
    'order_id' => 1510,
    'order_key' => 'wc_order_56233378102da',
    'downloads_remaining' => '',
    'access_expires' => NULL,
    'file' => 
    array (
      'name' => '04 McBurney\'s Jig.wma',
      'file' => 'http://127.0.0.1/sound/wp-content/uploads/woocommerce_uploads/2013/06/04-McBurneys-Jig.wma',
    ),
    'product_cat_dw' => 'Preset Banks',
    'product_cat_id' => 84,
    'product_tag_dw' => 'Kontakt',
    'product_tag_id' => 87,
  ),
)

        $downloads_massive = array();
foreach ($downloads_new as $download3):
    $prod_cat_name = $download3['product_cat_dw'];
    if (!array_key_exists($prod_cat_name, $downloads_massive)):
        $downloads_massive[$prod_cat_name] = array();    
    endif;
    unset($download3['product_cat_dw']);
    array_push($downloads_massive[$prod_cat_name], $download3);
endforeach;
unset($download3);
echo "<pre>"; print_r($downloads_massive); echo "</pre>"; 
?>