Is there an easy way to substitute a/an in a string to agree with the following word - much the same as the way 'S' works in Date format?
e.g.
$apple = 'apple';
$pear = 'pear';
echo "This is a $apple, this is a $pear."
--> This is an apple, this is a pear
Rule #1 - Specific identity not known: Use the indefinite article a or an only with a singular count noun whose specific identity is not known to the reader. Use a before nouns that begin with a consonant sound, and use an before nouns that begin with a vowel sound.
In English, there are only two indefinite articles, "a" and "an." In Spanish, there are four indefinite articles, un, una, unos, and unas. Spanish and English have different grammatical rules concerning when indefinite articles are needed or should be omitted.
An indefinite article is an article that refers to a noun without specifying it or refers to a noun to introduce it for the first time. For example, the sentence I saw a dog at the park uses the indefinite article a.
The indefinite article is used to refer to something for the first time or to refer to a particular member of a group or class. Some use cases and examples are given below.
Check this out, it passed my own testing, seems pretty solid.
https://github.com/Kaivosukeltaja/php-indefinite-article
I've forked the module Luke Chavers refers to, cleaning it up, fixing a logic error and making it integrable using Composer; with that installed, you can pull it into your project with:
php composer.phar require thaumatic/indefinite-article
The source code is at https://github.com/thaumatic/indefinite-article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With