Correct use of the plural in PHP and correct use of the plural in PHP

Source: Internet
Author: User

Correct use of the plural in PHP and correct use of the plural in PHP

1 <? Php 2 // correctly display the plural value 3 if (! Function_exists ('_ plurals_format ')) 4 {5/** 6 * correct use of the plural: 7 * @ access public 8 * @ author zhaoyingnan 2016-02-17 9 * @ param string $ sPluralName non-plural name 10 * @ param int $ iAmount quantity 11 * @ return string 12 * @ note 13 **/14 function _ plurals_format ($ sPluralName, $ iAmount) 15 {16 if (! $ SPluralName |! Is_numeric ($ iAmount) | $ iAmount <= 0) 17 return ''; 18 // special Plural Form 19 $ arPluralName = array (20 'addendum' => 'addenda', 21 'alga' => 'algae ', 22 'alipay' => 'alipay', 23 'alipay' => 'alipay', 24 'analys' => 'analys', 25 'anta' => 'antennas ', // antennae 26 'apparatus' => 'apparatuses ', 27 'appendix' => 'appendices', // appendixes 28' axis' => 'axes ', 29 'bacilli' => 'bacilli', 30 'bactery' => 'bactera', 31 'basis' => 'bases', 32 'beau '=> 'beaux ', 33 'bison '=> 'bison', 34 'buffalo' => 'buffalos ', // buffaloes 35 'bureau' => 'bureaus ', 36 'bus' => 'buss', // buses 37 'cactus '=> 'cactus', // cacti 38 'calf' => 'calves ', 39 'child '=> 'children', 40 'corps' => 'corps', 41 'corpus' => 'partition ', // corpuses 42 'crisis '=> 'cristers', 43 'criterion' => 'critera', 44 'curriculum '=> 'curricula ', 45 'datum '=> 'data', 46 'deer' => 'deer', 47 'die' => 'dice', 48 'dwarf' => 'dwarfs ', // dwarves 49 'diagnosis '=> 'diagnoses', 50' echo '=> 'choes', 51 'elf' => 'elves ', 52 'ellipsis '=> 'ellipses', 53 'embargo '=> 'embargoes', 54 'emphases' => 'emphases', 55 'erratum' => 'erata ', 56 'Fireman '=> 'firemen', 57 'fish '=> 'fish', // fishes 58 'focal '=> 'focuses ', 59 'foot' => 'feet ', 60 'formula' => 'formulas', 61 'fung' => 'fungi ', // funguses 62 'genus' => 'genera ', 63 'goose' => 'geese', 64 'half' => 'halves ', 65 'hero' => 'heroes ', 66 'hippotamus' => 'hippopotam', // hippopotamuses 67 'hoof' => 'hoofs ', // hooves 68 'hybrid' => 'hybrid', 69 'index' => 'indices', // indexes 70' knife '=> 'knives ', 71 'leaf' => 'leaf', 72 'LIFE' => 'lives ', 73 'loaf' => 'loaf', 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' => 'nebuclae ', // nebulas 85 'neurosis '=> 'neuroses', 86 'synus' => 'syni', 87 'oases' => 'oases ', 88 'octopus' => 'octoppi ', // octopuses 89 'ovum' => 'ova ', 90 'ox' => 'oxen ', 91 'paralysis '=> 'paralyses', 92 'parenthesis '=> 'parentheses', 93 'person '=> 'people', 94 'phenomenon' => 'phenomena ', 95 'potato' => 'potates', 96 'radius '=> 'radii', // radiuses 97 'scens' => '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' => 'stra', 106 'labus' => 'labi', // syllabuses107 'symposium '=> 'symposia ', // symposiums108 'Synthesis '=> 'synthes', 109 'synopsis' => 'synopses ', 110 'tableau' => 'tableaux ', 111 'that' => 'those ', 112 'thesis' => 'thes', 113 'thief' => 'thieves', 114 'this' => 'thes ', 115 'tomato' => 'tomates', 116 'tooth '=> 'teeth', 117 'Torpedo' => 'torpedoes', 118 'vertebra' => 'vertebrae ', 119 'veto '=> 'vetoels', 120 'Vita' => 'vitae ', 121 'Watch' => 'watches ', 122 'wife' => 'wives ', 123 'Wolf '=> 'Wolves', 124 'Woman '=> 'women', 125 'zero' => 'zeros ', // zeroes126 ); 127 128 // if only one 129 if ($ iAmount = 1) 130 return $ sPluralName; 131 132 // if more than one, and it is a special plural form 133 if (isset ($ arPluralName [$ sPluralName]) 134 return $ arPluralName [$ sPluralName]; 135 136 // more than one, and is a standard plural form 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. ';

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.