我有一个名词数据库(ex"house","感叹号","苹果"),我需要在我的应用程序中输出和描述.很难用一个自然的句子来描述一个项目而不使用"a"或"an" - "房子很大","感叹号很小"等等.
我可以在PHP中使用任何函数,库或hack来确定用A或AN描述任何给定名词是否更合适?
是否有一种简单的方法来替换字符串中的/ a以符合以下单词 - 与'S'在日期格式中的工作方式非常相似?
例如
$apple = 'apple';
$pear = 'pear';
echo "This is a $apple, this is a $pear."
--> This is an apple, this is a pear
Run Code Online (Sandbox Code Playgroud)