Reply to Re: singular or plural output string

Your name:

Reply:


Posted by Bosconian on 01/14/06 09:08

"Andy Hassall" <andy@andyh.co.uk> wrote in message
news:4khgs1tf5qao7mdc7r1t72753n5ov22mrj@4ax.com...
> On Fri, 13 Jan 2006 16:24:03 -0800, "Bosconian" <bosconian@planetx.com>
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?
> >
> >$results always contain 1 or more records so "0 appointments" is not
> >applicable.
> >
> >Is there a way to do this in one line (perhaps with regular expressions)
> >without resorting to something lame like "1 appointment(s)"?
> >
> >Again, no biggie and the above syntax is tried and true, but it's always
> >nice to learn a new trick now and then.
>
> I tend to use something like:
>
> print $count . ' noun' . ($count == 1 ? '' : 's')
>
> --
> Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
> http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

That works nicely--thanks!

[Back to original 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

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