【发布时间】:2014-02-12 08:58:29
【问题描述】:
<?php
$utf8string = "سلامجهان";
echo substr($utf8string,0,5);
?>
//output سل�
如何修复 php 中 utf-8 的 substr()?
【问题讨论】:
-
你在找
mb_substr(),可以看到here。
<?php
$utf8string = "سلامجهان";
echo substr($utf8string,0,5);
?>
//output سل�
如何修复 php 中 utf-8 的 substr()?
【问题讨论】:
mb_substr(),可以看到here。
<?php
$utf8string = "سلامجهان";
echo mb_substr($utf8string,0,5,'UTF-8');
//output سلامج
?>
使用mb_substr 并为其设置utf-8!
//sample mb_substr($YourString,first char,length of output char,charset name);
【讨论】: