• PHP正确的使用复数


      1 <?php
      2 // 正确地显示复数
      3 if(!function_exists('_plurals_format'))
      4 {
      5     /**
      6      * 正确的使用复数    
      7      * @access   public
      8      * @author   zhaoyingnan   2016-02-17 11:53
      9      * @param    string        $sPluralName    非复数形式的名称
     10      * @param    int           $iAmount        数量
     11      * @return   string
     12      * @note    
     13      **/
     14     function _plurals_format($sPluralName, $iAmount)
     15     {
     16         if(!$sPluralName || !is_numeric($iAmount) || $iAmount <= 0)
     17             return '';
     18         // 特殊的复数形式
     19         $arPluralName = array(
     20             'addendum'=>'addenda',
     21             'alga'=>'algae',
     22             'alumna'=>'alumnae',
     23             'alumnus'=>'alumni',
     24             'analysis'=>'analyses',
     25             'antenna'=>'antennas',//antennae
     26             'apparatus'=>'apparatuses',
     27             'appendix'=>'appendices',//appendixes
     28             'axis'=>'axes',
     29             'bacillus'=>'bacilli',
     30             'bacterium'=>'bacteria',
     31             'basis'=>'bases',
     32             'beau'=>'beaux',
     33             'bison'=>'bison',
     34             'buffalo'=>'buffalos',//buffaloes
     35             'bureau'=>'bureaus',
     36             'bus'=>'busses',//buses
     37             'cactus'=>'cactuses',//cacti
     38             'calf'=>'calves',
     39             'child'=>'children',
     40             'corps'=>'corps',
     41             'corpus'=>'corpora',//corpuses
     42             'crisis'=>'crises',
     43             'criterion'=>'criteria',
     44             'curriculum'=>'curricula',
     45             'datum'=>'data',
     46             'deer'=>'deer',
     47             'die'=>'dice',
     48             'dwarf'=>'dwarfs',//dwarves
     49             'diagnosis'=>'diagnoses',
     50             'echo'=>'echoes',
     51             'elf'=>'elves',
     52             'ellipsis'=>'ellipses',
     53             'embargo'=>'embargoes',
     54             'emphasis'=>'emphases',
     55             'erratum'=>'errata',
     56             'fireman'=>'firemen',
     57             'fish'=>'fish',//fishes
     58             'focus'=>'focuses',
     59             'foot'=>'feet',
     60             'formula'=>'formulas',
     61             'fungus'=>'fungi',//funguses
     62             'genus'=>'genera',
     63             'goose'=>'geese',
     64             'half'=>'halves',
     65             'hero'=>'heroes',
     66             'hippopotamus'=>'hippopotami',//hippopotamuses
     67             'hoof'=>'hoofs',//hooves
     68             'hypothesis'=>'hypotheses',
     69             'index'=>'indices',//indexes
     70             'knife'=>'knives',
     71             'leaf'=>'leaves',
     72             'life'=>'lives',
     73             'loaf'=>'loaves',
     74             'louse'=>'lice',
     75             'man'=>'men',
     76             'matrix'=>'matrices',
     77             'means'=>'means',
     78             'medium'=>'media',
     79             'memorandum'=>'memoranda',
     80             'millennium'=>'millenniums',//milennia
     81             'moose'=>'moose',
     82             'mosquito'=>'mosquitoes',
     83             'mouse'=>'mice',
     84             'nebula'=>'nebulae',//nebulas
     85             'neurosis'=>'neuroses',
     86             'nucleus'=>'nuclei',
     87             'oasis'=>'oases',
     88             'octopus'=>'octopi',//octopuses
     89             'ovum'=>'ova',
     90             'ox'=>'oxen',
     91             'paralysis'=>'paralyses',
     92             'parenthesis'=>'parentheses',
     93             'person'=>'people',
     94             'phenomenon'=>'phenomena',
     95             'potato'=>'potatoes',
     96             'radius'=>'radii',//radiuses
     97             'scarf'=>'scarfs',//scarves
     98             'self'=>'selves',
     99             'series'=>'series',
    100             'sheep'=>'sheep',
    101             'shelf'=>'shelves',
    102             'scissors'=>'scissors',
    103             'species'=>'species',
    104             'stimulus'=>'stimuli',
    105             'stratum'=>'strata',
    106             'syllabus'=>'syllabi',//syllabuses
    107             'symposium'=>'symposia',//symposiums
    108             'synthesis'=>'syntheses',
    109             'synopsis'=>'synopses',
    110             'tableau'=>'tableaux',
    111             'that'=>'those',
    112             'thesis'=>'theses',
    113             'thief'=>'thieves',
    114             'this'=>'these',
    115             'tomato'=>'tomatoes',
    116             'tooth'=>'teeth',
    117             'torpedo'=>'torpedoes',
    118             'vertebra'=>'vertebrae',
    119             'veto'=>'vetoes',
    120             'vita'=>'vitae',
    121             'watch'=>'watches',
    122             'wife'=>'wives',
    123             'wolf'=>'wolves',
    124             'woman'=>'women',
    125             'zero'=>'zeros',//zeroes
    126         );
    127 
    128         // 如果只有一个
    129         if($iAmount == 1)
    130             return $sPluralName;
    131 
    132         // 如果超过一个,并且是特殊的复数形式
    133         if(isset($arPluralName[$sPluralName]))
    134             return $arPluralName[$sPluralName];
    135 
    136         // 超过一个,并且是一个标准的复数形式
    137         return $sPluralName.'s';
    138     }
    139 }
    140 
    141 echo 'Sybil ate three '._plurals_format('biscuit', 3).', one after the other.',PHP_EOL;
    142 echo 'The two '._plurals_format('woman', 2).' will meet tomorrow in the final.';
  • 相关阅读:
    十年经验大牛浅谈自动化测试与测试用例的编写
    从功能测试到自动化测试,携程大牛总结一些工作经验分享
    阿里大牛谈软件测试面试的几个建议
    记一个Selenium自动化测试网页
    腾讯大牛教你简单的自动化测试模型(Python+Selenium)
    阿里大牛教你基于Python的 Selenium自动化测试示例解析
    携程大牛谈自动化测试里的数据驱动和关键字驱动思路的理解
    论:关于自动化测试的前期发展历史及未来发展趋势
    阿里大牛教你一分钟了解自动化测试
    绑定银行卡的一些细节
  • 原文地址:https://www.cnblogs.com/yingnan/p/5194817.html
Copyright © 2020-2023  润新知