如何检查单词中的元音

时间:2017-03-07 06:57:10

标签: javascript php jquery

如果我定义一个简单的单词变量,我将如何以简单的方式计算和输出单词中元音的数量?

我已经搜索并发现了许多类似的方法,但大多数似乎比必要的更复杂,但我正在寻找最简单的解决方案。

我的单词变量类似于:

$word = "Apple"

我只想 显示a,e,i,o,u 的总实例。

提前谢谢。

1 个答案:

答案 0 :(得分:1)

<?php
$string = "This is some text with some more text and even more text.";
echo "There are <strong>".preg_match_all('/[aeiou]/i',$string,$matches)." vowels</strong> in the string <strong>".$string."</strong>";
?>

我希望它能帮到你