Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $bales = array(
- 2 => array(
- array(
- 'design' => 'D1',
- 'color' => 'RED'
- ),
- array(
- 'design' => 'D3',
- 'color' => 'PINK'
- ),
- array(
- 'design' => 'D1',
- 'color' => 'BLUE'
- )
- ),
- 1 => array(
- array(
- 'design' => 'D2',
- 'color' => 'BLUE'
- ),
- array(
- 'design' => 'D1',
- 'color' => 'WHITE'
- )
- )
- );
- ksort($bales);
- foreach($bales as $baleNumber => &$rows){
- $design = array();
- $color = array();
- // Obtain a list of columns
- foreach ($rows as $key => $column) {
- $design[$key] = $column['design'];
- $color[$key] = $column['color'];
- }
- array_multisort($design, SORT_ASC, $color, SORT_ASC, $rows);
- }
- var_dump($bales);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement