ฉันต้องการรับคำที่ใช้มากที่สุดจากอาร์เรย์ ปัญหาเดียวคืออักขระภาษาสวีเดน (Å, Ä และ Ö) จะแสดงเป็น � เท่านั้น
$string = 'This is just a test post with the Swedish characters Å, Ä, and Ö. Also as lower cased characters: å, ä, and ö.';
echo '<pre>';
print_r(array_count_values(str_word_count($string, 1, 'àáãâçêéíîóõôúÀÁÃÂÇÊÉÍÎÓÕÔÚ')));
echo '</pre>';
รหัสนั้นจะแสดงผลดังต่อไปนี้:
Array
(
[This] => 1
[is] => 1
[just] => 1
[a] => 1
[test] => 1
[post] => 1
[with] => 1
[the] => 1
[Swedish] => 1
[characters] => 2
[�] => 1
[�] => 1
[and] => 2
[�] => 1
[Also] => 1
[as] => 1
[lower] => 1
[cased] => 1
[�] => 1
[�] => 1
[�] => 1
)
ฉันจะทำให้ "เห็น" ตัวอักษรภาษาสวีเดนและตัวอักษรพิเศษอื่นๆ ได้อย่างไร?
str
ซึ่งไม่ปลอดภัยสำหรับหลายไบต์ ความคิดเห็นของผู้ใช้ในคู่มือแนะนำทางเลือกอื่น - person CBroe   schedule 24.09.2016...PHP function with a name starting with str...
ฟังก์ชันนี้อยู่ที่ไหน - person SaidbakR   schedule 24.09.2016mb_str_word_count
แทนstr_word_count
: stackoverflow.com/a/17725577/6797531 - person CatalinB   schedule 24.09.2016Array([This is just a test post with the Swedish characters �, �, and Ö. Also as lower cased characters: �, �, and �.] => 1)
- person Airikr   schedule 24.09.2016