Return to Snippet

Revision: 52151
at October 14, 2011 17:01 by wanchun0222


Updated Code
$arr = array(    

    'index'=>array( 'name'=>'首页','order'=>3),

    'intro'=>array( 'name'=>'企业概况','order'=>2),

    'news'=>array( 'name'=>'新闻动态','order'=>1 ),

    'product'=>array( 'name'=>'产品中心','order'=>4 ),

    'message'=>array( 'name'=>'访客留言','order'=>7 ),

    'position'=>array( 'name'=>'人才招聘','order'=>6),

    'contact'=>array( 'name'=>'联系我们','order'=> 5 )

);

uasort($arr, 'cmp');

public function cmp($a, $b){

   return $a['order'] - $b['order'];

}

Revision: 52150
at October 14, 2011 17:00 by wanchun0222


Updated Code
$arr = array(    

    'index'=>array( 'name'=>'�页','order'=>3),

    'intro'=>array( 'name'=>'����','order'=>2),

    'news'=>array( 'name'=>'����','order'=>1 ),

    'product'=>array( 'name'=>'产�中�','order'=>4 ),

    'message'=>array( 'name'=>'访客��','order'=>7 ),

    'position'=>array( 'name'=>'人���','order'=>6),

    'contact'=>array( 'name'=>'�系�们','order'=> 5 )

);

uasort($arr, 'cmp');

public function cmp($a, $b){

   return $a['order'] - $b['order'];

}

Revision: 52149
at October 14, 2011 16:59 by wanchun0222


Updated Code
$arr = array(    

    'index'=>array( 'name'=>'�页','order'=>3),

    'intro'=>array( 'name'=>'����','order'=>2),

    'news'=>array( 'name'=>'����','order'=>1 ),

    'product'=>array( 'name'=>'产�中�','order'=>4 ),

    'message'=>array( 'name'=>'访客��','order'=>7 ),

    'position'=>array( 'name'=>'人���','order'=>6),

    'contact'=>array( 'name'=>'�系�们','order'=> 5 )

);

uasort($arr, 'cmp');

public function cmp($a, $b){

   return $a['order'] - $b['order'];

}

Revision: 52148
at October 14, 2011 16:58 by wanchun0222


Initial Code
$arr = array(    

    'index'=>array( 'name'=>'首页','order'=>3),

    'intro'=>array( 'name'=>'企业概况','order'=>2),

    'news'=>array( 'name'=>'新闻动态','order'=>1 ),

    'product'=>array( 'name'=>'产品中心','order'=>4 ),

    'message'=>array( 'name'=>'访客留言','order'=>7 ),

    'position'=>array( 'name'=>'人才招聘','order'=>6),

    'contact'=>array( 'name'=>'联系我们','order'=> 5 )

);

uasort($arr, 'cmp');

public function cmp($a, $b){

   return $a['order'] - $b['order'];

}

Initial URL
http://www.coderbolg.com/content/144.html

Initial Description

                                

Initial Title
[php] multi-dimensional array sort

Initial Tags
sort, array

Initial Language
PHP