|
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]
|