<?php
// 正确地显示复数
if(!function_exists('_plurals_format'))
{
/**
* 正确的使用复数
* @access public
* @author zhaoyingnan 2016-02-17 11:53
* @param string $sPluralName 非复数形式的名称
* @param int $iAmount 数量
* @return string
* @note
**/
function _plurals_format($sPluralName, $iAmount)
{
if(!$sPluralName || !is_numeric($iAmount) || $iAmount <= 0)
return '';
// 特殊的复数形式
$arPluralName = array(
'addendum'=>'addenda',
'alga'=>'algae',
'alumna'=>'alumnae',
'alumnus'=>'alumni',
'analysis'=>'analyses',
'antenna'=>'antennas',//antennae
'apparatus'=>'apparatuses',
'appendix'=>'appendices',//appendixes
'axis'=>'axes',
'bacillus'=>'bacilli',
'bacterium'=>'bacteria',
'basis'=>'bases',
'beau'=>'beaux',
'bison'=>'bison',
'buffalo'=>'buffalos',//buffaloes
'bureau'=>'bureaus',
'bus'=>'busses',//buses
'cactus'=>'cactuses',//cacti
'calf'=>'calves',
'child'=>'children',
'corps'=>'corps',
'corpus'=>'corpora',//corpuses
'crisis'=>'crises',
'criterion'=>'criteria',
'curriculum'=>'curricula',
'datum'=>'data',
'deer'=>'deer',
'die'=>'dice',
'dwarf'=>'dwarfs',//dwarves
'diagnosis'=>'diagnoses',
'echo'=>'echoes',
'elf'=>'elves',
'ellipsis'=>'ellipses',
'embargo'=>'embargoes',
'emphasis'=>'emphases',
'erratum'=>'errata',
'fireman'=>'firemen',
'fish'=>'fish',//fishes
'focus'=>'focuses',
'foot'=>'feet',
'formula'=>'formulas',
'fungus'=>'fungi',//funguses
'genus'=>'genera',
'goose'=>'geese',
'half'=>'halves',
'hero'=>'heroes',
'hippopotamus'=>'hippopotami',//hippopotamuses
'hoof'=>'hoofs',//hooves
'hypothesis'=>'hypotheses',
'index'=>'indices',//indexes
'knife'=>'knives',
'leaf'=>'leaves',
'life'=>'lives',
'loaf'=>'loaves',
'louse'=>'lice',
'man'=>'men',
'matrix'=>'matrices',
'means'=>'means',
'medium'=>'media',
'memorandum'=>'memoranda',
'millennium'=>'millenniums',//milennia
'moose'=>'moose',
'mosquito'=>'mosquitoes',
'mouse'=>'mice',
'nebula'=>'nebulae',//nebulas
'neurosis'=>'neuroses',
'nucleus'=>'nuclei',
'oasis'=>'oases',
'octopus'=>'octopi',//octopuses
'ovum'=>'ova',
'ox'=>'oxen',
'paralysis'=>'paralyses',
'parenthesis'=>'parentheses',
'person'=>'people',
'phenomenon'=>'phenomena',
'potato'=>'potatoes',
'radius'=>'radii',//radiuses
'scarf'=>'scarfs',//scarves
'self'=>'selves',
'series'=>'series',
'sheep'=>'sheep',
'shelf'=>'shelves',
'scissors'=>'scissors',
'species'=>'species',
'stimulus'=>'stimuli',
'stratum'=>'strata',
'syllabus'=>'syllabi',//syllabuses
'symposium'=>'symposia',//symposiums
'synthesis'=>'syntheses',
'synopsis'=>'synopses',
'tableau'=>'tableaux',
'that'=>'those',
'thesis'=>'theses',
'thief'=>'thieves',
'this'=>'these',
'tomato'=>'tomatoes',
'tooth'=>'teeth',
'torpedo'=>'torpedoes',
'vertebra'=>'vertebrae',
'veto'=>'vetoes',
'vita'=>'vitae',
'watch'=>'watches',
'wife'=>'wives',
'wolf'=>'wolves',
'woman'=>'women',
'zero'=>'zeros',//zeroes
); // 如果只有一个
if($iAmount == 1)
return $sPluralName; // 如果超过一个,并且是特殊的复数形式
if(isset($arPluralName[$sPluralName]))
return $arPluralName[$sPluralName]; // 超过一个,并且是一个标准的复数形式
return $sPluralName.'s';
}
} echo 'Sybil ate three '._plurals_format('biscuit', 3).', one after the other.',PHP_EOL;
echo 'The two '._plurals_format('woman', 2).' will meet tomorrow in the final.';

PHP正确的使用复数的更多相关文章

  1. rails日记1

    assert_select "div" <div>foobar</div>assert_select "div", "foob ...

  2. MATLAB的基本元素

    MALTAB程序的基本数据单元是数组,MATLAB 的变量名必须以字母开头,后面可以跟字母,数字和下划线(_).只有前31个字符是有效的:如果超过了31 个字符,基余的字符将被忽略.如果声明两个变量, ...

  3. java 实现傅立叶变换算法 及复数的运算

    最近项目需求,需要把python中的算法移植到java上,其中有一部分需要用到复数的运算和傅立叶变换算法,废话不多说 如下: package qrs; /** * 复数的运算 * */ public ...

  4. in+sb's+基数词的复数形式|UFO|the minutes|

    Hawking became world-famous in ________.  A. his thirties in the 1970's  B. the thirties in his 1970 ...

  5. 利用JavaScript与正则表达式判断输入账号格式是否正确

    在学习了HTML DOM对象后,做几个小练习来巩固一下所学内容. 正则表达式: 正则表达式,又称规则表达式.(英语:Regular Expression,在代码中常简写为regex.regexp或RE ...

  6. Git 在团队中的最佳实践--如何正确使用Git Flow

    我们已经从SVN 切换到Git很多年了,现在几乎所有的项目都在使用Github管理, 本篇文章讲一下为什么使用Git, 以及如何在团队中正确使用. Git的优点 Git的优点很多,但是这里只列出我认为 ...

  7. 如何正确使用日志Log

    title: 如何正确使用日志Log date: 2015-01-08 12:54:46 categories: [Python] tags: [Python,log] --- 文章首发地址:http ...

  8. WebAPi之SelfHost自创建证书启动Https疑难解惑及无法正确返回结果

    前言 话说又来需求了,之前对于在SelfHost中需要嵌套页面并操作为非正常需求,这回来正常需求了,客户端现在加了https,老大过来说WebAPi访问不了了,这是什么情况,我去试了试,还真是这个情况 ...

  9. javascript匹配各种括号书写是否正确

    今天在codewars上做了一道题,如下 看上去就是验证三种括号各种嵌套是否正确书写,本来一头雾水,一种括号很容易判断, 但是三种怎么判断! 本人只是个前端菜鸟,,不会什么高深的正则之类的. 于是,在 ...

随机推荐

  1. percona server 5.7.16正式发布

    继2016年10月12日mysql 5.7.16发布后,percona server 5.7.16终于于11月29日发布了,这是最新版本的5.7系列,可从https://www.percona.com ...

  2. 学习zepto.js(Hello World)

    Zepto是一个轻量级的针对现代高级浏览器的JavaScript库, 它与jquery有着类似的api. 如果你会用jquery,那么你也会用zepto. 昨天听说了zepto.js,正好最近也比较闲 ...

  3. 原创QQ影音DLL劫持漏洞+动画实战教程

    1.什么是DLL DLL(Dynamic Link Library)文件为动态链接库文件,又称“应用程序拓展”,是软件文件类型.在Windows中,许多应用程序并不是一个完整的可执行文件,它们被分割成 ...

  4. ora-00119和ora-00132解决方案

    win7 64位    oracle 11g  先登录到sqlplus: sqlplus /nolog; 登录数据库: conn system/manager as sysdba; 然后启动数据库: ...

  5. CSS 选择器 关系

    常见的基于关系的选择器 选择器        选择的元素 A E    元素A的任一后代元素E (后代节点指A的子节点,子节点的子节点,以此类推) A > E   元素A的任一子元素E(也就是直 ...

  6. Android Action Bar简介

    Android Action Bar简介 Design: Action Bar Action Bar是在屏幕顶端的一部分内容,通常在整个app进行中都保持存在. 它提供了几个关键的功能: 1.使得重要 ...

  7. Android执行程序或脚本的方法

    Java中提供了两种方法来执行程序或脚本: (1) 使用Runtime的exec()方法 (2) 使用ProcessBuilder的start()方法 ProcessBuilder.start() 和 ...

  8. 【iOS】彩色TabBar切换动画实现

    无意间看到一个彩色TabBar切换的设计图,感觉很不错,有空就把他实现了. 环境信息 Mac OS X 10.10.4 Xcode 6.4 iOS 8.4 效果图: 效果图 源码下载地址: https ...

  9. XML解析之SAX详解

    XML解析之SAX详解 本文属于作者原创 http://www.cnblogs.com/ldnh/ XML解析的五个步骤 1.打开文档 (void)parserDidStartDocument:(NS ...

  10. C++语言-08-命名空间

    概述 命名空间通常作为附加信息来区分不同库中相同名称的函数.类.变量.命名空间的本质是定义一个范围,该范围即为一个上下文,一个上下文中通常不允许出现相同名称的函数.类.变量. 定义 定义格式 普通的命 ...