Skip to content

Instantly share code, notes, and snippets.

View jamescridland's full-sized avatar

James Cridland jamescridland

View GitHub Profile
@samstarling
samstarling / indefinite_article.php
Created February 21, 2011 22:14
Gets your a's/an's correct. Originally from http://james.cridland.net/code/
<?
// Usage:
echo "I have ".return_indefinitearticle("apple")." apple, and ".return_indefinitearticle("slice of bread")." slice of bread.";
function return_indefinitearticle($thing) {
return (preg_match('/^[aeiou]|s\z/i', strtolower($thing))) ? "an" : "a";
}
?>