Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct form of indefinite article (a, an) in PHP strings

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
like image 326
Leo Avatar asked Aug 26 '10 14:08

Leo


People also ask

When we use indefinite article a and an?

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.

What are the 4 indefinite articles?

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.

What is an indefinite article example?

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.

What is indefinite article in English grammar?

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.


2 Answers

Check this out, it passed my own testing, seems pretty solid.

https://github.com/Kaivosukeltaja/php-indefinite-article

like image 167
Luke Chavers Avatar answered Oct 25 '22 08:10

Luke Chavers


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.

like image 34
chaos Avatar answered Oct 25 '22 07:10

chaos