<?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. 把复杂json解析成javabean

    工具:fastjson1.2.9 用其他工具也行,比如json-lib.gson 用法都差不多 先来一段json { "page": { "pagenow": ...

  2. 用Microsoft.Solver.Foundation进行线性规划,为WPF应用添加智能

    在管理信息系统的开发过程中,往往会涉及到一些线性规划数学模型,例如资源配置优化.微软的Microsoft.Solver.Foundation是一个数学库,可以很好的对线性规划问题进行求解.关于它的细节 ...

  3. 过去几个月出炉的30款最喜欢的 jQuery 插件

    在这篇文章中,我们收集了一些在过去的几个月里最喜欢的 jQuery 插件.为了使您更容易搜索到自己喜欢的 jQuery 插件,我们已经对插件进行了分类: 页面布局插件,图片和视频插件,滑块和画廊,排版 ...

  4. 20款美化网站的 jQuery Lightbox 灯箱插件

    jQuery Lightbox 灯箱插件可以让你为您的网站和应用程序展示优雅的图像,视频 和其它内容(使用模式窗口).如果你是一个开发人员,你必须拥有 jQuery 灯箱插件集合,因为有一部分的客户会 ...

  5. Ubuntu Desktop 15.10 自带桌面共享问题修复

    Ubuntu 15.10 (似乎从14.04开始) 的小坑,使用自带远程桌面连接出错,弄得我很不爽,偶尔从 youtube 上看到一视频,解决了.聊以记之. 顺便说一下,这个自带的桌面共享的名字是:v ...

  6. 前端上传组件Plupload使用指南

    我之前写过一篇文章<文件上传利器SWFUpload使用指南>,里面介绍了上传组件SWFUpload的使用方法,但现在随着html5技术的逐渐推广和普及,再去使用以flash为上传手段的SW ...

  7. angular源码分析:angular中jqLite的实现——你可以丢掉jQuery了

    一.从function JQLite(element)函数开始. function JQLite(element) { if (element instanceof JQLite) { //情况1 r ...

  8. 分享一个我的JavaScript版GridView多功能表格

    GridView是什么? GridView是由Mr.Co开发的一套开源的多功能表格插件,主要用于让页面开发者在开发中节省拼接Table表格和操作Table表格相关复杂操作的开发成本与时间.开发人员可以 ...

  9. VSTO开发,转帖

    http://www.cnblogs.com/oneivan/p/4243574.html

  10. 编译安装mysql(Ubuntu10 64位)

    选用较好的编译器和较好的编译器选项,这样应用可提高性能10-30%,这个对大多数程序都非常重要 Mysql的编译,不同的版本具体的配置方式是有差别的 旧版的配置形式参考 这个形式主要是使用config ...