當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。