
A? or An? Get your indefinite articles right
"Peter is a Assocate Editor". Eurgh. That didn't look very nice. I needed to correctly use 'a' and 'an', like how you should.
This little function probably does what you want.
<?
//Use like this:
echo "I have ".return_indefinitearticle("apple")." apple, and ".return_indefinitearticle("slice of bread")." slice of bread.";
// which should return 'an apple' and 'a slice of bread'.
function return_indefinitearticle($thing) {
if(preg_match('/^[aeiou]|s\z/i', strtolower($thing))) {
return "an";
} else {
return "a";
}
}
?>