2017-03-07 6 views
-3

単純な単語変数を定義すると、単純に単語の母音の数をどのように数えて出力するのですか?単語の母音を確認する方法

これまで同様の方法をいくつか検索して見つけましたが、ほとんどは必要以上に複雑に見えますが、私は可能な限り簡単な解決方法を探しています。私はちょうどディスプレイに、E、I、O、Uの合計インスタンスをしたい

$word = "Apple" 

マイワード変数は次のようなものになるだろう。

ありがとうございます。

+2

は、すべての母音を含むマップを作成するのに役立つカウンタを返すことを願っています。 – SuperTetelman

+0

http://stackoverflow.com/questions/29450399/counting-number-of-vowels-in-a-string-with-javascript –

+0

http://stackoverflow.com/questions/7465304/simple-way-to-count -the-in-a-string-in-php – mrahmat

答えて

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>"; 
?> 

は、私はそれは、現在の文字がvowels_mapである場合、カウンタをインクリメント、単語内のすべての文字を反復処理、あなた

関連する問題