JpnForPhp\Analyzer\Analyzer::countHiragana PHP Method

countHiragana() public static method

Count number of hiragana within the specified string.
public static countHiragana ( string $str ) : integer
$str string The input string.
return integer Returns the number of hiragana.
    public static function countHiragana($str)
    {
        $matches = array();
        return preg_match_all(Helper::PREG_PATTERN_HIRAGANA, $str, $matches);
    }

Usage Example

Example #1
0
 public function testCountHiraganaWhenSutegana()
 {
     $result = Analyzer::countHiragana('ぁぃぅぇぉ');
     $this->assertEquals(5, $result);
 }