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


PHP array_count_values函数代码示例

本文整理汇总了PHP中array_count_values函数的典型用法代码示例。如果您正苦于以下问题:PHP array_count_values函数的具体用法?PHP array_count_values怎么用?PHP array_count_values使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: PhpaieLogin

function PhpaieLogin()
{
    $pg_LIVEUSER1LOGIN = new LIVEUSER1LOGIN(isset($_POST) && array_count_values($_POST) ? $_POST : $_GET);
    //Récupération des variables pour le formulaire
    $pg_LIVEUSER1LOGIN->pageDisplay("");
    //exit();
}
开发者ID:BackupTheBerlios,项目名称:phpaie,代码行数:7,代码来源:liveuser1login.php

示例2: search_AddWords

function search_AddWords(&$obj, $module = 'Search', $id = -1, $attr = '', $content = '', $expires = NULL)
{
    $obj->DeleteWords($module, $id, $attr);
    $db =& $obj->GetDb();
    $non_indexable = strpos($content, NON_INDEXABLE_CONTENT);
    if ($non_indexable !== FALSE) {
        return;
    }
    @$obj->SendEvent('SearchItemAdded', array($module, $id, $attr, &$content, $expires));
    if ($content != "") {
        //Clean up the content
        $stemmed_words = $obj->StemPhrase($content);
        $words = array_count_values($stemmed_words);
        $q = "SELECT id FROM " . cms_db_prefix() . 'module_search_items WHERE module_name=?';
        $parms = array($module);
        if ($id != -1) {
            $q .= " AND content_id=?";
            $parms[] = $id;
        }
        if ($attr != '') {
            $q .= " AND extra_attr=?";
            $parms[] = $attr;
        }
        $dbresult = $db->Execute($q, $parms);
        if ($dbresult && $dbresult->RecordCount() > 0 && ($row = $dbresult->FetchRow())) {
            $itemid = $row['id'];
        } else {
            $itemid = $db->GenID(cms_db_prefix() . "module_search_items_seq");
            $db->Execute('INSERT INTO ' . cms_db_prefix() . 'module_search_items (id, module_name, content_id, extra_attr, expires) VALUES (?,?,?,?,?)', array($itemid, $module, $id, $attr, $expires != NULL ? trim($db->DBTimeStamp($expires), "'") : NULL));
        }
        foreach ($words as $word => $count) {
            $db->Execute('INSERT INTO ' . cms_db_prefix() . 'module_search_index (item_id, word, count) VALUES (?,?,?)', array($itemid, $word, $count));
        }
    }
}
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:35,代码来源:search.tools.php

示例3: WordIntoDB

function WordIntoDB($url, $fileID, $db)
{
    $path = $url;
    $fp = fopen($path, 'r');
    $contents = stream_get_contents($fp);
    $contents = strip_tags($contents);
    $contents = strtolower($contents);
    $i = 0;
    $sep = " \n\t\"\\'!,.()''\"~!@#\$%^&*(),./<>\\+_=-|?;:[]{}`бу^1234567890";
    $acontents[$i++] = trim(strtok($contents, $sep));
    while ($token = strtok($sep)) {
        $acontents[$i++] = trim($token);
    }
    $count = array_count_values($acontents);
    ksort($count);
    if (!ini_get('safe_mode')) {
        set_time_limit(0);
    }
    foreach ($count as $row => $times) {
        //echo $row."=>".$times."<br>";
        $word_id = $db->InsertWord($row);
        $db->InsertFileWords($fileID, $word_id, $times);
    }
    fclose($fp);
}
开发者ID:Zhiming,项目名称:PHP,代码行数:25,代码来源:InsertWord.php

示例4: reussite

function reussite($date, $ent)
{
    $sqlReussite = "select * from kazak_cheval where entraineur='{$ent}' and dateAnnee='{$date}' and rang between 1 and 3";
    $resReussite = mysql_query($sqlReussite);
    //var_dump($res);
    echo "<b>" . $ent . " <i>(" . $date . ")</i></b>";
    echo "<br>";
    //echo "<table><tr><td>";
    $arrayHypodrome = array();
    while ($dataReussite = mysql_fetch_array($resReussite)) {
        $hypodrome = $dataReussite['hypodrome'];
        //echo $entraineur;
        $arrayHypodrome[] = $hypodrome;
        //echo 	$arrayEntraineur[$i];
        //echo $i=$i+1;
        //echo "<br>";
    }
    $result = array_count_values($arrayHypodrome);
    arsort($result);
    foreach ($result as $cle => $value) {
        // echo $cle.' => '.$value.'<br/>';
        if ($value > 3) {
            echo $cle . ' => ' . $value . '<br/>';
        }
        //else {echo "moins de 3 reussites pour l'ensemble des hippodromes";	 }
    }
    echo "</span></a>";
}
开发者ID:kazakSite,项目名称:KTV1,代码行数:28,代码来源:function.php

示例5: compareCommonDates

 /**
  * Establish if there is a day
  * witch matches for all people
  * @param caldates
  * @return Day 
  */
 public function compareCommonDates(CalendarDateRepository $calDates)
 {
     $dates = $calDates->getDates();
     //get the number of peope
     $numberOfPeople = count($dates);
     $dateArr = array();
     $dayNameArr = array();
     //flatten the array...
     foreach ($dates as $date) {
         foreach ($date as $value) {
             $dateArr[] = $value;
             $dayNameArr[] = $value->getName();
         }
     }
     //check if there is a value with the same amount of matches as people
     $countArr = array_count_values($dayNameArr);
     if (in_array($numberOfPeople, $countArr)) {
         //get the value of the index
         $day = array_search($numberOfPeople, $countArr);
         foreach ($dateArr as $date) {
             if ($date->getName() == $day) {
                 //TODO how handle multiple days matching? new calendarDateRepo?
                 return $date;
             }
         }
     }
     return null;
 }
开发者ID:henceee,项目名称:hg222dv-1DV449-Webteknik-ii,代码行数:34,代码来源:compareData.php

示例6: getSuccess

 /**
  * 获取成功的订单
  * @return [type] [description]
  */
 public function getSuccess()
 {
     $data = array('main' => url('/'), 'announce' => url('/announce'), 'category' => url('/category'), 'deliver' => url('/deliver'), 'good' => url('/good'), 'map' => url('/map'), 'shop_info' => url('/shop_info'), 'success' => url('/success'), 'widge_success' => array());
     $shop_id = Auth::user()->shop_id;
     $orders = Order::where('shop_id', $shop_id)->where('state_of_shop', 3)->get();
     $data['widge_success']['deal_count'] = count($orders);
     $data['widge_success']['deal'] = array();
     $shop = Shop::find($shop_id);
     foreach ($orders as $order) {
         $comment = CommentOrder::where('order_id', $order->id)->get();
         $one = array('deal_id' => $order->id, 'deal_statue' => $order->state, 'same_again' => '##', 'deal_again' => '##', 'shop_name' => $shop->name, 'deal_number' => $order->number, 'deal_time' => date('Y-m-d', $order->ordertime), 'deal_phone' => $shop->linktel, 'deliver_address' => $order->receive_address, 'deliver_phone' => $order->receive_phone, 'deliver_remark' => $order->beta, 'deal_speed' => isset($comment[0]) ? $comment[0]->speed : 0, 'deal_satisfied' => isset($comment[0]) ? $comment[0]->value : 0, 'good' => array(), 'others' => array(array('item_name' => '不知道', 'item_value' => '-5', 'item_amount' => '1', 'item_total' => '0')));
         $one['total'] = $order->total;
         $menu_ids = array_count_values(explode(',', $order->order_menus));
         foreach ($menu_ids as $menu_id => $amount) {
             $menuComment = CommentMenu::where('order_id', $order->id)->where('menu_id', $menu_id)->get();
             $menu = Menu::find($menu_id);
             //var_dump($menuComment);
             $onemenu = array('goods_id' => $menu_id, 'goods_name' => $menu->title, 'goods_value' => $menu->price, 'goods_amount' => $amount, 'goods_total' => $amount * $menu->price, 'good_atisfied' => isset($menuComment[0]) ? $menuComment[0]->value : 0);
             array_push($one['good'], $onemenu);
         }
         array_push($data['widge_success']['deal'], $one);
     }
     return View::make("template.success.success")->with($data);
     //var_dump($data);
 }
开发者ID:andycall,项目名称:map_admin_RD,代码行数:29,代码来源:HomeController.php

示例7: index

 public function index(array $params = [])
 {
     Assets::addCSS('svgtree-0.3.0.min.css');
     Assets::addCSS('main.css');
     Assets::addJS('jsrender.min.js');
     Assets::addJS('db.js');
     Assets::addJS('main.js');
     Assets::addJS('search.js');
     Assets::addJS('svgtree-0.3.0.min.js');
     Assets::addJS('trees.js');
     $this->SearchModel = $this->loader->loadModel('Search');
     if (isset($_POST['words'])) {
         $words = json_decode($_POST['words']);
         $results = $this->SearchModel->searchFromKeywords($words);
         $response = [];
         // if we have some results to handle
         if ($results) {
             // count values
             $results = array_count_values($results);
             // sort by count
             arsort($results);
             // keep only sorted links id
             $results = array_keys($results);
             foreach ($results as $linkId) {
                 $link = $this->SearchModel->getLink($linkId);
                 if ($link) {
                     $response[] = $link;
                 }
             }
         }
         echo json_encode($response);
         exit;
     }
     $this->loader->loadView('index', $this->data, true);
 }
开发者ID:cocochepeau,项目名称:si-dev,代码行数:35,代码来源:IndexController.php

示例8: calculate

 private function calculate($move, $warPlace, $playerName)
 {
     $coordinates = $move->getCoordenates();
     $x = $coordinates['x'];
     $y = $coordinates['y'];
     $feedback = new Feedback();
     $result = array(isset($warPlace[$x - 1][$y + 1]) ? $warPlace[$x - 1][$y + 1] : null, isset($warPlace[$x][$y + 1]) ? $warPlace[$x][$y + 1] : null, isset($warPlace[$x + 1][$y + 1]) ? $warPlace[$x + 1][$y + 1] : null, isset($warPlace[$x - 1][$y]) ? $warPlace[$x - 1][$y] : null, isset($warPlace[$x + 1][$y]) ? $warPlace[$x + 1][$y] : null, isset($warPlace[$x - 1][$y - 1]) ? $warPlace[$x - 1][$y - 1] : null, isset($warPlace[$x][$y - 1]) ? $warPlace[$x][$y - 1] : null, isset($warPlace[$x + 1][$y - 1]) ? $warPlace[$x + 1][$y - 1] : null);
     $rEnd = array();
     foreach ($result as $idx => $r) {
         if (!is_null($r)) {
             $rEnd[] = $r;
         }
     }
     $count = array_count_values($rEnd);
     asort($count);
     unset($count['.']);
     if (count($count) == 0) {
         $feedback->add(Feedback::WIN, $move);
         return $feedback;
     }
     $dominanteId = key($count);
     $dominanteCount = array_shift($count);
     if ($dominanteId == $playerName || $dominanteId == '.') {
         $feedback->add(Feedback::WIN, $move);
         return $feedback;
     }
     if ($dominanteCount == 1) {
         $feedback->add(Feedback::WIN, $move);
         return $feedback;
     }
     $feedback->add(Feedback::LOSE, $move);
     return $feedback;
 }
开发者ID:iannsp,项目名称:phpwar,代码行数:33,代码来源:Neibor.php

示例9: doMobileshow

 public function doMobileshow()
 {
     global $_W, $_GPC;
     $rid = $_GPC['id'];
     $sql = "SELECT * FROM " . tablename($this->tablename_log) . " WHERE `rid`=:rid";
     $info = pdo_fetchall($sql, array(':rid' => $rid));
     $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `rid`=:rid LIMIT 1";
     $quiz = pdo_fetch($sql, array(':rid' => $rid));
     $sql = "SELECT * FROM " . tablename($this->tablename_question) . " WHERE `id`=:id";
     $q = pdo_fetch($sql, array(':id' => $quiz['qid']));
     //var_dump($q);
     $arr = array();
     foreach ($info as $key => $value) {
         $arr[] = $info[$key]['chk_answer'];
     }
     $per = array_count_values($arr);
     ksort($per);
     //var_dump($per);
     $total_count = sizeof($info);
     $config = $this->get_config($q);
     //foreach($per as $key => $value){
     //$str .= '选项'.$key.'次数'.$value;
     //}
     //var_dump($str);
     //var_dump($per);
     include $this->template('show');
 }
开发者ID:alextiannus,项目名称:wormwood_wechat,代码行数:27,代码来源:site.php

示例10: getStatistics

 public function getStatistics()
 {
     $integrated = array();
     // Bands
     $sql = 'select gig_bands as bands from gigs';
     $rows = $this->db()->query($sql);
     while ($row = $this->db()->fetch_array($rows)) {
         $bandsArrayRow = explode('+', $row['bands']);
         foreach ($bandsArrayRow as $band) {
             if (strpos($band, ':')) {
                 $bandTrimmed = explode(":", $band);
                 $integrated[] = utf8_encode(trim($bandTrimmed[1]));
             } else {
                 $integrated[] = utf8_encode(trim($band));
             }
         }
     }
     $sql = 'select count(*) as gigs from gigs';
     $rows2 = $this->db()->query($sql);
     $row2 = $this->db()->fetch_array($rows2);
     $stats['gigs'] = $row2;
     $stats['bandsNumber'] = count(array_count_values($integrated));
     $stats['integrated'] = array_count_values($integrated);
     return $stats;
 }
开发者ID:xyulex,项目名称:music,代码行数:25,代码来源:Music.class.php

示例11: Get_Color

 /**
  * Returns the colors of the image in an array, ordered in descending order, where the keys are the colors, and the values are the count of the color.
  *
  * @return array
  */
 function Get_Color()
 {
     if (isset($this->image)) {
         $im = $this->image;
         $imgWidth = imagesx($im);
         $imgHeight = imagesy($im);
         for ($y = 0; $y < $imgHeight; $y++) {
             for ($x = 0; $x < $imgWidth; $x++) {
                 $index = imagecolorat($im, $x, $y);
                 $Colors = imagecolorsforindex($im, $index);
                 $Colors['red'] = intval(($Colors['red'] + 15) / 32) * 32;
                 //ROUND THE COLORS, TO REDUCE THE NUMBER OF COLORS, SO THE WON'T BE ANY NEARLY DUPLICATE COLORS!
                 $Colors['green'] = intval(($Colors['green'] + 15) / 32) * 32;
                 $Colors['blue'] = intval(($Colors['blue'] + 15) / 32) * 32;
                 if ($Colors['red'] >= 256) {
                     $Colors['red'] = 240;
                 }
                 if ($Colors['green'] >= 256) {
                     $Colors['green'] = 240;
                 }
                 if ($Colors['blue'] >= 256) {
                     $Colors['blue'] = 240;
                 }
                 $hexarray[] = substr("0" . dechex($Colors['red']), -2) . substr("0" . dechex($Colors['green']), -2) . substr("0" . dechex($Colors['blue']), -2);
             }
         }
         $hexarray = array_count_values($hexarray);
         natsort($hexarray);
         $hexarray = array_reverse($hexarray, true);
         return $hexarray;
     } else {
         die("You must enter a filename! (\$image parameter)");
     }
 }
开发者ID:Apothems,项目名称:naranai,代码行数:39,代码来源:colors.inc.php

示例12: parse

 /**
  * Template method. Main algorithm
  *
  * {@inheritdoc}
  */
 public function parse(array $options)
 {
     $this->checkOptions($options);
     $this->declaredNamespaces = $options['declared_namespaces'];
     $pattern = '#\\b((?<module>(' . implode('[\\\\]|', $this->declaredNamespaces) . '[\\\\])[a-zA-Z0-9]+)[a-zA-Z0-9_\\\\]*)\\b#';
     $modules = [];
     foreach ($options['files_for_parse'] as $file) {
         $content = file_get_contents($file);
         $module = $this->extractModuleName($file);
         // also collect modules without dependencies
         if (!isset($modules[$module])) {
             $modules[$module] = ['name' => $module, 'dependencies' => []];
         }
         if (preg_match_all($pattern, $content, $matches)) {
             $dependencies = array_count_values($matches['module']);
             foreach ($dependencies as $dependency => $count) {
                 if ($module == $dependency) {
                     continue;
                 }
                 if (isset($modules[$module]['dependencies'][$dependency])) {
                     $modules[$module]['dependencies'][$dependency]['count'] += $count;
                 } else {
                     $modules[$module]['dependencies'][$dependency] = ['lib' => $dependency, 'count' => $count];
                 }
             }
         }
     }
     return $modules;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:34,代码来源:Code.php

示例13: hasDuplicatedValues

 private function hasDuplicatedValues(array $values)
 {
     $duplicatedValues = array_filter(array_count_values($values), function ($counter) {
         return $counter !== 1;
     });
     return empty($duplicatedValues) === false;
 }
开发者ID:lebris,项目名称:karma,代码行数:7,代码来源:GroupParser.php

示例14: solution

function solution($A)
{
    $counta = count($A);
    $countleaders = 0;
    for ($i = 0; $i < $counta - 1; $i++) {
        $front[$i] = array_slice($A, 0, $i + 1);
        $after[$i] = array_slice($A, $i + 1, $counta - $i - 1);
        //print_r($front[$i]);
        //print_r($after[$i]);
        $countfront = count($front[$i]);
        $countafter = count($after[$i]);
        $maxfront = current(array_keys(array_count_values($front[$i]), max(array_count_values($front[$i]))));
        $maxafter = current(array_keys(array_count_values($after[$i]), max(array_count_values($after[$i]))));
        //echo $countfront;
        //echo $countafter;
        //echo max(array_count_values($front[$i])).'.';
        //echo max(array_count_values($after[$i])).'.';
        //echo $maxfront;
        //echo $maxafter;
        //echo $maxafter;
        if (max(array_count_values($front[$i])) > $countfront / 2 && max(array_count_values($after[$i])) > $countafter / 2 && $maxfront === $maxafter) {
            $countleaders++;
        }
    }
    return $countleaders;
}
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:26,代码来源:EquiLeader_test.php

示例15: __construct

 /**
  * Constructor
  *
  * @param array $characterMap
  * @throws \InvalidArgumentException
  */
 public function __construct(array $characterMap)
 {
     // Trim characters of whitespaces
     array_walk($characterMap, function (&$char) {
         $char = trim($char);
     });
     $nonSingleCharacters = array();
     foreach ($characterMap as $character) {
         if (strlen($character) > 1) {
             $nonSingleCharacters[] = $character;
         }
     }
     if (count($nonSingleCharacters)) {
         throw new \InvalidArgumentException("The character map contains references that aren't 1 character in length: '" . implode("' '", $nonSingleCharacters) . "'");
     }
     $frequencies = array_count_values($characterMap);
     $duplicates = array();
     foreach ($frequencies as $character => $frequency) {
         if ($frequency > 1) {
             $duplicates[] = $character;
         }
     }
     if (count($duplicates)) {
         throw new \InvalidArgumentException("The character map contains duplicates of the following characters: '" . implode("' '", $duplicates) . "'");
     }
     $this->characterMap = $characterMap;
 }
开发者ID:choccybiccy,项目名称:algorithms,代码行数:33,代码来源:LuhnModN.php


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