Thread: a or an
View Single Post
  #1  
Old 01-05-2007, 08:21 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
a or an

Well, when you see title I think that you think it's something about grammar,
well, script wise it is; is there a way to see if a string should have 'a' or 'an' infront? Instead of having a private function like..

PHP Code:
temp.foo = { "a", "e", "u", "i", "o", "y"};
temp.bar = "test";

return ( 
temp.bar.substring( 0, 1) in temp.foo ? "an" : "a") SPC temp.bar;

// would produce 'a test' 
Is there an easier way? ( well, thats easy, just looking if there is a built-in or something, or it could of been suggested..)
__________________

Last edited by Chompy; 01-05-2007 at 08:34 PM..
Reply With Quote