PHP正确的使用复数
2016-02-17 11:37
501 查看
<?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.';
相关文章推荐
- phpstorm10.0.3汉化方法:
- Yes It Is(Yii)_缓存(cache)详解
- php 静态话技术
- php配置伪静态的方法
- 三种实现PHP伪静态页面的方法
- PHP获取汉字首字母函数
- php 之跨域上传图片 (smallnews笔记)
- php fopen file_get_contents curl区别
- php功能开发-手机验证码
- php ThinkPHP文章上一篇、下一篇解决方案
- Yii2有返回结果集的存储过程调用
- php导出到excel表格里
- php检索相关文章
- #一次性#向文件#写入#字符串或#追加#字符串最合适 PHP file_put_contents()
- HDphp框架评论、关注、私信的制作教程
- HDphp框架目录说明
- 后盾HDphp框架笔记总结
- PHP支付宝接口开发
- php与java通用AES加密解密算法
- PHP:echo中逗号与点号的区别