Saya ingin mendapatkan kata yang paling sering digunakan dari sebuah array. Satu-satunya masalah adalah karakter Swedia (Å, Ä, dan Ö) hanya akan ditampilkan sebagai �.
$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>';
Kode itu akan menampilkan yang berikut:
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
)
Bagaimana saya bisa "melihat" karakter Swedia dan karakter khusus lainnya?
str
tidak aman untuk multi-byte. Komentar pengguna di manual menyarankan alternatif. - person CBroe   schedule 24.09.2016...PHP function with a name starting with str...
di mana fungsi ini? - person SaidbakR   schedule 24.09.2016mb_str_word_count
sebagai gantinyastr_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