fork download
  1. <?php
  2. $oldarray =[[
  3. 'barang_id' => '7389',
  4. 'spec' => 'KCH8AT-DM',
  5. 'heat_no' => '7B4784',
  6. 'coil_no' => '0210',
  7. 'size' => '17.9',
  8. 'weight' => '2014',
  9. 'container' => 'TCLU6265556',
  10. ],[
  11. 'barang_id' => '7390',
  12. 'spec' => 'KCH8AT-DM',
  13. 'heat_no' => '7B4784',
  14. 'coil_no' => '0050',
  15. 'size' => '17.9',
  16. 'weight' => '2006',
  17. 'container' => 'TCLU6265556'
  18. ]
  19. ];
  20. $newarray =[];
  21. foreach($oldarray as $value) {
  22. $newarray[$value['barang_id']] = $value;
  23.  
  24. }
  25. print_r($newarray);
  26. // your code goes here
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
Array
(
    [7389] => Array
        (
            [barang_id] => 7389
            [spec] => KCH8AT-DM
            [heat_no] => 7B4784
            [coil_no] => 0210
            [size] => 17.9
            [weight] => 2014
            [container] => TCLU6265556
        )

    [7390] => Array
        (
            [barang_id] => 7390
            [spec] => KCH8AT-DM
            [heat_no] => 7B4784
            [coil_no] => 0050
            [size] => 17.9
            [weight] => 2006
            [container] => TCLU6265556
        )

)