我有一個子字符串函數的問題。當一個特殊的char是結果子字符串的最後一個字符(只有!!!)時,這個字符被表示爲一個帶有問號的圖標。PHP:特殊字符變成問號圖標子字符串
這裏說到我的代碼:
$string = 'This is a string and when a German word with a special char like "Tür" appears and the special char ü is the last character of the substring it gets represented as an icon with question mark';
echo substr($string,0,102). "...";
結果:
這是一個字符串,當一個德語單詞包含「TUR」 出現和特殊字符特殊字符..
我該如何避免這種情況?
使用'mb_substr' – Rein