Skip to content

Instantly share code, notes, and snippets.

View jamescridland's full-sized avatar

James Cridland jamescridland

View GitHub Profile
@jamescridland
jamescridland / indefinite_article.php
Created February 21, 2011 23:01 — forked from samstarling/indefinite_article.php
A little bit of PHP to return "a" and "an" correctly.
<?
// 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";
}
?>