2014-11-04 4 views
0

는 히브리어 language.Following은 아마 내가 히브리어는 '2'가 아닌 0으로 계산 받아야 스 니펫PHP 히브리어 글자 수

<?php 
$e_str="This is football";// 3 words 
$h_str="זה כדורגל";//hebrew translation of above 
$h_str= trim(addslashes($h_str)); 
echo 'English Count : '.str_word_count(mb_convert_encoding($e_str, 'HTML-ENTITIES', 'ISO-8859-1')).'<br/>';//prints 3 

echo 'Hebrew Count : '.str_word_count(html_entity_decode(mb_convert_encoding($h_str,'HTML-ENTITIES','UTF-8'),ENT_QUOTES,'UTF-8'));//prints zero 
?> 

이기 문자의 수를 계산 확인 어쨌든입니다. 어떤 해결책이 있습니까?

+0

http://stackoverflow.com/questions/8290537/is-php-str-word-count-multibyte-safe @Hanky ​​웃 사람이에요 –

+0

감사합니다. . 괜찮아요. 감사합니다. @Scimonster –

답변

1

공백으로 나누고 배열 길이를 계산하십시오.

echo 'Hebrew Count : '.count(explode(' ', html_entity_decode(mb_convert_encoding($h_str,'HTML-ENTITIES','UTF-8'),ENT_QUOTES,'UTF-8')));//prints 2 
+0

나중에이 작품과 실제 개수에 가까운 계산 제공 –