Created
October 3, 2011 11:58
-
-
Save robwilkerson/1258957 to your computer and use it in GitHub Desktop.
Attempts to intelligently use "a" and "an" in a sentence.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$l = array( 'a apple is a fruit', 'a banana is also a fruit' ); | |
foreach( $l as $s ) { | |
$s = preg_replace( '/(^| )a ([aeiouAEIOU])/', '$1an $2', $s ); | |
echo $s . "\n"; | |
} | |
# outputs | |
an apple is a fruit | |
a banana is also a fruit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment