<?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. 巧用loadrunner代理,录制手机APP脚本

    利用loadrunner代理方式录制手机(iPhone.android)应用程序HTTP脚本 1.利用笔记本网卡或者类似360随身wifi,在安装loadrunner的电脑上共享网络,在手机上连接共享 ...

  2. 小白linux安装php 5.6+nginx配置(踩坑版)

    因为要搭建个知识库,直接用wordpress,这前提是得先装php,实在不喜欢XAMPP,所以自己折腾,没想到php这一来还不少啊,从头到尾折腾了一个小时多.记录下主要的流程和遇到的坑. 首先官网下载 ...

  3. mysql出错:Access denied for user 'root'@'localhost' (using password: YES)

    网站链接mysql数据库的时候,连接不上,并报出错误:Access denied for user 'root'@'localhost' (using password:YES) 这是个相当恼火的问题 ...

  4. SQLServer2008部署镜像

    SQL Server 2008 R2数据库镜像部署 概述 “数据库镜像”是一种针对数据库高可用性的基于软件的解决方案.其维护着一个数据库的两个相同的副本,这两个副本分别放置在不同的SQL Server ...

  5. Spring4学习笔记 - 配置Bean - 自动装配 关系 作用域 引用外部属性文件

    1 Autowire自动装配 1.1 使用:只需在<bean>中使用autowire元素 <bean id="student" class="com.k ...

  6. IClient for js开发之地图的加载

    进行web开发之前首先需要安装IServer以及iClient for JavaScript的开发包.在这两中都具备的前提下进行第一步,如何调用IServer中发布的服务 调用iServer 中发布的 ...

  7. 酷!使用 jQuery & Canvas 制作相机快门效果

    在今天的教程中,我们将使用 HTML5 的 Canvas 元素来创建一个简单的摄影作品集,它显示了一组精选照片与相机快门的效果.此功能会以一个简单的 jQuery 插件形式使用,你可以很容易地整合到任 ...

  8. 使用 jQuery Mockjax 插件模拟 Ajax 请求

    在实际的开发过程中,前端后台协商好了统一的接口,就各自开始自己的任务了.这时候我有这么一个 Ajax 请求需要从后台获取数据: $.ajax({ url: '/products/' }).done(f ...

  9. 批量另存mxd

    在GIS数据处理中,批量操作是经常遇到的问题,Python脚本是解决问题的最好方法.现在需要将arcgis10.1的mxd另存为10.0,不仅数量较多,而且每个mxd要素和标注非常多,手动来操作确实慢 ...

  10. VMware: XXX is still busy. Please wait until the operation is complete before closing

      在使用vmware的过程中发现创建快照.恢复快照.管理快照等功能突然都变成灰色的,用不了.更觉得夸张的是仅仅剩下关闭虚机按钮是红色的.心想估计是虚机快照没处理完之类的问题导致的,于是想想关闭虚机重 ...