You are here: Re: singular or plural output string « PHP Programming Language « IT news, forums, messages
Re: singular or plural output string

Posted by Oli Filth on 09/26/65 11:37

Bosconian said the following on 16/01/2006 21:03:
>> <john.d.mann@sbcglobal.net> wrote in message
>> news:f9syf.9425$dW3.1196@newssvr21.news.prodigy.com...
>>> Bosconian wrote:
>>>> This might seem like a trivial thing, but has anyone has come up with
>>>> a better way of outputting a singular vs. plural string?
>>>>
>>>>
>>> Well, you can always put that code into a function in its own php file
>>> and then just include it in your php file which will use it... Then you
>>> could call it on one line each time you needed it. For example:
>>>
>>> include('printplural.php');
>>> ...
>>> print_plural($mystring, $db_result);
>>> ...
>
> On second thought, breaking this out as a function proves useful:
>
> function print_plural($temp, $count) {
> return $count . ' ' . $temp . ($count == 1 ? '' : 's');
> }
>
> print print_plural('appointment', mysql_num_rows($result));
>

Of course, beware of non-standard pluralisation, e.g. "children",
"geese", "bacteria", "fish", "mice", "oxen", etc.


--
Oli

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация