Advertisement
Guest User

Untitled

a guest
Sep 5th, 2012
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2. $out=array(
  3. 1 => array('name'=>'Бананы','count'=>16),
  4. 2 => array('name'=>'Груши','count'=>12),
  5. 3 => array('name'=>'Яблоки','count'=>1),
  6. 4 => array('name'=>'Апельсины','count'=>1),
  7. 5 => array('name'=>'Мандарины','count'=>5),
  8. );
  9. $tmp=array();
  10. foreach($out as $item){
  11.      $tmp['name'][]=$item['name'];
  12.      $tmp['count'][]=$item['count'];
  13. }
  14. array_multisort($tmp['count'],SORT_ASC,$out);//,$tmp['sort'],SORT_DESC,$out);
  15. print_r($out);
  16. /*
  17.  
  18. Array
  19. (
  20.     [0] => Array
  21.         (
  22.             [name] => Апельсины
  23.             [count] => 1
  24.         )
  25.  
  26.     [1] => Array
  27.         (
  28.             [name] => Яблоки
  29.             [count] => 1
  30.         )
  31.  
  32.     [2] => Array
  33.         (
  34.             [name] => Мандарины
  35.             [count] => 5
  36.         )
  37.  
  38.     [3] => Array
  39.         (
  40.             [name] => Груши
  41.             [count] => 12
  42.         )
  43.  
  44.     [4] => Array
  45.         (
  46.             [name] => Бананы
  47.             [count] => 16
  48.         )
  49.  
  50. )
  51. */
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement