Advertisement
Guest User

Untitled

a guest
Nov 28th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. $bales = array(
  3.     2 => array(
  4.         array(
  5.             'design' => 'D1',
  6.             'color' => 'RED'
  7.         ),
  8.         array(
  9.             'design' => 'D3',
  10.             'color' => 'PINK'
  11.         ),
  12.         array(
  13.             'design' => 'D1',
  14.             'color' => 'BLUE'
  15.         )
  16.     ),
  17.     1 => array(
  18.         array(
  19.             'design' => 'D2',
  20.             'color' => 'BLUE'
  21.         ),
  22.         array(
  23.             'design' => 'D1',
  24.             'color' => 'WHITE'
  25.         )
  26.     )
  27. );
  28. ksort($bales);
  29. foreach($bales as $baleNumber => &$rows){
  30.     $design = array();
  31.     $color = array();
  32.     // Obtain a list of columns
  33.     foreach ($rows as $key => $column) {
  34.         $design[$key] = $column['design'];
  35.         $color[$key] = $column['color'];
  36.     }
  37.     array_multisort($design, SORT_ASC, $color, SORT_ASC, $rows);
  38. }
  39. var_dump($bales);
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement