不带空格的utf-8字符的php substr() //产出�
如何在php中修复utf-8的substr()?可以看出,您正在寻找。第三个参数是长度,而不是结束位置。不带空格的utf-8字符的php substr() //产出�,php,substring,substr,Php,Substring,Substr,如何在php中修复utf-8的substr()?可以看出,您正在寻找。第三个参数是长度,而不是结束位置。 <?php $utf8string = "سلامجهان"; echo substr($utf8string,0,5); ?> //output سل� <?php $utf8string = "سلامجهان"; echo mb_substr($utf8string,0,5,'UTF-8');
<?php
$utf8string = "سلامجهان";
echo substr($utf8string,0,5);
?>
//output سل�
<?php
$utf8string = "سلامجهان";
echo mb_substr($utf8string,0,5,'UTF-8');
//output سلامج
?>
//sample mb_substr($YourString,first char,length of output char,charset name);