zoukankan      html  css  js  c++  java
  • array_multisort根据字段给数组排序

    1 foreach($result as $v){
    2 $t[] = $v['created'];
    3 }
    4  array_multisort($t,SORT_DESC, $result); //排序

    1 $ar = array (
    2  array ( 'key' => '69931',
    3 'hname' => 'eee',
    4 'hsex' => '',
    5 'hhunfou' => '未婚',
    6 'hshouji' => 'ee',
    7 'hmail' => 'er',
    8 'ips' => '24#72.30.142.252',
    9 'hqq' => 're',
    10 'ifpaishe' => 2,
    11 'username' => 'jiayang3401',
    12 'clicks' => 10,
    13 'hyinglou' => '' ),
    14  array ( 'key' => '81',
    15 'hname' => 'susan',
    16 'hsex' => '',
    17 'hhunfou' => '未婚',
    18 'hshouji' => '0000',
    19 'hmail' => '0000',
    20 'ips' => '24#72.30.142.252#221.215.68.22#221.3.83.98',
    21 'hqq' => '0000',
    22 'ifpaishe' => 1,
    23 'username' => 'susan',
    24 'clicks' => 15,
    25 'hyinglou' => '摄影名店' ),
    26  array ( 'key' => '101440',
    27 'hsex' => '',
    28 'hhunfou' => '已婚',
    29 'hshouji' => '13853276763',
    30 'ips' => '24#202.160.179.19#221.3.83.98',
    31 'ifpaishe' => 2,
    32 'username' => 'NIKI',
    33 'clicks' => 3,
    34 'hyinglou' => '' ),
    35  array ( 'key' => '101440',
    36 'hsex' => '',
    37 'hhunfou' => '已婚',
    38 'hshouji' => '13853276763',
    39 'ips' => '24#202.160.179.19#221.3.83.98',
    40 'ifpaishe' => 2,
    41 'username' => 'NIKI',
    42 'clicks' => 3,
    43 'hyinglou' => '' ),
    44  array ( 'key' => '101440',
    45 'hsex' => '',
    46 'hhunfou' => '已婚',
    47 'hshouji' => '13853276763',
    48 'ips' => '24#202.160.179.19#221.3.83.98',
    49 'ifpaishe' => 2,
    50 'username' => 'NIKI',
    51 'clicks' => 3,
    52 'hyinglou' => '' ),
    53 array ( 'key' => '101440',
    54 'hsex' => '',
    55 'hhunfou' => '已婚',
    56 'hshouji' => '13853276763',
    57 'ips' => '24#202.160.179.19#221.3.83.98',
    58 'ifpaishe' => 2,
    59 'username' => 'NIKI',
    60 'clicks' => 3,
    61 'hyinglou' => '' ),
    62 array ( 'key' => '101440',
    63 'hsex' => '',
    64 'hhunfou' => '已婚',
    65 'hshouji' => '13853276763',
    66 'ips' => '24#202.160.179.19#221.3.83.98',
    67 'ifpaishe' => 2,
    68 'username' => 'NIKI',
    69 'clicks' => 3,
    70 'hyinglou' => '' ),
    71 );
    72
    73
    74 foreach($ar as $v)
    75 $t[] = $v['clicks'];
    76
    77 array_multisort($t, $ar); //排序
    78 print_r(array_slice($ar, 0, 3)); //取出前3条
    79

    aliyun活动 https://www.aliyun.com/acts/limit-buy?userCode=re2o7acl
  • 相关阅读:
    ios实现下拉刷新,上拉加载
    ios实现瀑布流
    ios收货地址三级联动选择
    ios仿淘宝管理收货地址demo
    引用传值
    继承小结
    is操作符和as操作符
    抽象类和object类
    重写基类
    派生
  • 原文地址:https://www.cnblogs.com/wangbin/p/1833722.html
Copyright © 2011-2022 走看看