当前位置: 首页>>代码示例>>PHP>>正文


PHP helper::array_sort方法代码示例

本文整理汇总了PHP中helper::array_sort方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::array_sort方法的具体用法?PHP helper::array_sort怎么用?PHP helper::array_sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helper的用法示例。


在下文中一共展示了helper::array_sort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: m__list

function m__list()
{
    //判断操作权限
    check_level("E08");
    global $dbm, $resource_list;
    // 查询 mcms_resource_list 表
    $params['where'] = " 1=1";
    $params['table_name'] = TB_PREFIX . "resource_list";
    $params['count'] = 1;
    $params['suffix'] = " order by id DESC ";
    $params['pagesize'] = PAGESIZE;
    $params['suffix'] .= $dbm->get_limit_sql(PAGESIZE, $_GET['p']);
    $resource_list = $dbm->single_query($params);
    //开始循环 进行比对数据 找出关联的资源
    $i = 0;
    //数组排序时用到
    foreach ($resource_list['list'] as $k => $v) {
        //调用函数对数据进行比对
        $result = check_resource($v['id'], $v['info_id'], $v['resource_url']);
        //添加排序元素
        if ($result['info']['table_name'] == 'undefined' && 'undefined' == $result['info']['qita']) {
            $resource_list['list'][$k]['paixu'] = ++$i;
        } else {
            $resource_list['list'][$k]['paixu'] = 0;
        }
        $resource_list['list'][$k]['info'] = $result['info'];
    }
    $resource_list['list'] = helper::array_sort($resource_list['list'], 'paixu', 'desc');
    //将无效资源排在前面
    //print_r($resource_list);exit;
}
开发者ID:cranefly,项目名称:crane,代码行数:31,代码来源:resource.php

示例2: get_tags_baidu

 /**
  * 根据百度搜索结果自动提取关键词
  * @param $title 要提取关键词的标题
  * @param $filter_words1 精准过滤词数组 array('过滤词1','过滤词2')
  * @param $filetr_words2 模糊过滤词数组 array('过滤词1','过滤词2')
  */
 public static function get_tags_baidu($title, $filter_words1 = array(), $filter_words2 = array())
 {
     if (strlen($title) <= 4) {
         die('{"code":1,"msg":"","data":["' . $title . '"]}');
     }
     $ret = helper::get_contents('http://www.baidu.com/s?wd=' . urlencode($title));
     preg_match_all('~<em>(.*?)</em>~', $ret, $keys);
     //过滤字符
     for ($i = 0; $i < count($keys[1]); $i++) {
         $keys[1][$i] = preg_replace('~"|\'|“|”|【|】|\\(|\\)|(|)|:|:|\\-|—~', '', $keys[1][$i]);
     }
     //去重并过滤
     $nkeys = array();
     foreach ($keys[1] as $a) {
         //去重
         $is_key = 0;
         for ($b = 0; $b < count($nkeys); $b++) {
             if ($a == $nkeys[$b]['k']) {
                 $is_key = 1;
                 $nkeys[$b]['t'] = 1 + $nkeys[$b]['t'];
                 break;
             }
         }
         //过滤
         $is_k1 = 0;
         foreach ($filter_words1 as $b) {
             if ($b == $a) {
                 $is_k1 = 1;
                 break;
             }
         }
         $is_k2 = 0;
         foreach ($filter_words2 as $b) {
             if (strstr($a, $b)) {
                 $is_k2 = 1;
                 break;
             }
         }
         if ($is_key == 0 && $is_k1 == 0 && $is_k2 == 0) {
             array_push($nkeys, array('k' => $a, 't' => 1, 'l' => strlen($a)));
         }
     }
     //过滤字符长度
     $tags = array();
     for ($i = 0; $i < count($nkeys); $i++) {
         if (strlen($nkeys[$i]['k']) >= 9 && strlen($nkeys[$i]['k']) <= 18) {
             array_push($tags, $nkeys[$i]);
         }
     }
     //排序
     $tags = helper::array_sort($tags, 'l');
     //print_r($info_tags);
     $ntags = array();
     //重做数组
     foreach ($tags as $a) {
         array_push($ntags, $a);
     }
     return $ntags;
 }
开发者ID:cranefly,项目名称:crane,代码行数:65,代码来源:helper.class.php

示例3: get_area

 /**
  * 根据位置ID获取(专题,推荐)
  * 如果是广告,则输出广告代码,如果是专题或者推荐信息则输出列表
  *
  * @param  $ 参数数组
  * @param  $area_id 位置ID
  * @param  $pagesize 分页大小
  * @param  $p 当前分页
  * @param  $count 是否统计分页
  * @param  $where 查询条件
  * @param  $order 专题内文档排序方式,默认为排序升序
  */
 function get_area($params)
 {
     $area_id = isset($params['area_id']) ? $params['area_id'] : 0;
     $pagesize = isset($params['pagesize']) ? $params['pagesize'] : PAGESIZE_F;
     $p = isset($params['p']) ? $params['p'] : 1;
     $count = isset($params['count']) ? $params['count'] : 0;
     $where = isset($params['where']) ? $params['where'] : '';
     $rewrite = isset($params['rewrite']) ? $params['rewrite'] : 2;
     $order = isset($params['order']) ? $params['order'] : '';
     if (!is_numeric($area_id)) {
         return array();
     }
     if ($area_id == 0) {
         // 如果位置ID=0,则取列表
         $recommend_list = array();
         $sql = "select * from " . TB_PREFIX . "recommend_area ";
         if ($where != '') {
             $sql .= " where {$where}";
         }
         $suffix = " order by area_order asc,area_id desc";
         // 拼接分页数据
         $suffix .= " limit " . ($p - 1) * $pagesize . ",{$pagesize}";
         $result = $this->dbm->query($sql, $suffix, $count);
         //print_r($result);
         //生成surl
         $count = count($result['list']);
         for ($i = 0; $i < $count; $i++) {
             $result['list'][$i]['surl'] = $this->url->encode('special_content', array('host' => SITE_PATH, 'id' => $result['list'][$i]['area_id']));
         }
         $total = $result['total'];
         // 分页码HTML
         if ($rewrite == 0 || $rewrite == 1) {
             // 前台使用动态地址或者伪静态地址
             if ($this->url != null) {
                 $result['pagebar'] = helper::pagebar(array('total' => $total, 'pagesize' => $pagesize, 'rewrite' => $rewrite, 'rule' => array('node' => $node, 'obj' => $this->url, 'params' => array('host' => '/', 'cate_id' => $cate_id, 'cname_py' => $this->categories[$cate_id]['cname_py'], 'p' => $p))));
             } else {
                 $result['pagebar'] = array('pagecode' => '');
             }
         } else {
             $result['pagebar'] = helper::pagebar(array('total' => $total, 'pagesize' => $pagesize, 'rewrite' => $rewrite));
         }
         return $result;
     } else {
         // 如果位置ID大于0,则取某个位置的数据
         $sql = "select * from " . TB_PREFIX . "recommend_area where area_id='{$area_id}' limit 1";
         $rs = $this->dbm->query($sql);
         $recommend = array();
         if (count($rs['list']) == 1) {
             $recommend = $rs['list'][0];
             //print_r($recommend);
             if ($recommend['area_type'] == 0) {
                 // 广告
                 $tmp_a = unserialize($recommend['area_html']);
                 $order = 1;
                 //print_r($tmp_a);
                 if (is_array($tmp_a['list'])) {
                     foreach ($tmp_a['list'] as $v) {
                         if (!isset($v['order'])) {
                             $order = 0;
                             break;
                         }
                     }
                     if ($order == 1) {
                         $tmp_arr = helper::array_sort($tmp_a['list'], 'order', 'asc');
                         $tmp = array();
                         foreach ($tmp_arr as $v) {
                             array_push($tmp, $v);
                         }
                         $tmp_a['list'] = $tmp;
                     }
                 }
                 $recommend = $tmp_a;
             } else {
                 // 专题,推荐
                 if ($order == '') {
                     $order = ' order by field(info_id,' . $recommend['id_list'] . ')';
                 }
                 //$list = $this -> get_list(array('where' => 'info_id in (' . $recommend['id_list'] . ')', 'pagesize' => $pagesize, 'order' => $order,'extern'=>$extern));
                 //$recommend['list'] = $list['list'];
             }
         }
         return $recommend;
     }
 }
开发者ID:cranefly,项目名称:crane,代码行数:96,代码来源:common.class.php

示例4: cate_son

 /**
  * 取分类的子分类,返回数组,树形结构
  *
  * @param  $cate_id 分类ID
  * 返回值为树形,因为子分类有可能是多分支的
  */
 public function cate_son($cate_id)
 {
     $ret = array();
     foreach ($this->categories() as $c) {
         if ($c['parent_id'] == $cate_id) {
             $c['son'] = $this->cate_son($c['cate_id']);
             array_push($ret, $c);
         }
     }
     $ret = helper::array_sort($ret, 'corder');
     return $ret;
 }
开发者ID:cranefly,项目名称:crane,代码行数:18,代码来源:category.model_old.php

示例5: m__get_recommend

function m__get_recommend()
{
    global $dbm;
    $area_id = isset($_POST['area_id']) ? intval($_POST['area_id']) : 0;
    $a = $dbm->query("select area_html from " . TB_PREFIX . "recommend_area where area_id='{$area_id}'");
    if (count($a['list']) == 0) {
        die('{"code":1,"msg":"获取广告失败"}');
    }
    $area_html = unserialize($a['list'][0]['area_html']);
    //print_r($area_html);
    $order = 1;
    //如果不是代码广告 根据area_html里面的type判断。图片imgs 代码广告是 code
    if ($area_html['type'] != 'code') {
        foreach ($area_html['list'] as $v) {
            if (!isset($v['order'])) {
                $order = 0;
                break;
            }
        }
        if ($order == 1) {
            $tmp_arr = helper::array_sort($area_html['list'], 'order', 'asc');
            $tmp = array();
            foreach ($tmp_arr as $v) {
                array_push($tmp, $v);
            }
            $area_html['list'] = $tmp;
            //print_r($area_html);
        }
    }
    $data = json_encode($area_html);
    die('{"code":0,"msg":"获取成功","data":' . $data . '}');
}
开发者ID:cranefly,项目名称:crane,代码行数:32,代码来源:ad.php


注:本文中的helper::array_sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。