doudai8083 2018-04-23 10:50
浏览 65
已采纳

PHP substr波斯语字符串以问号结尾

In PHP when I want to substr the Persian string 'حروف فارسی برای امتحان', and it appends the question mark at the end of string.

This is my code:

$a = 'حروف فارسی برای امتحان'; echo substr($a,0,10);

And the problem is حروف �

Anyone has any suggestion or solution for this regards? much appreciated.

  • 写回答

2条回答 默认 最新

  • dongliyan7318 2018-04-23 10:52
    关注

    use mb_substr($a,0,10,'utf-8') instead of substr() for Persian and Arabic characters

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • doutizong8099 2018-04-23 10:53
    关注

    PHP does not have multi-byte character support by default. You have to use mb_* functions, like

    mb_substr()
    

    http://php.net/manual/en/function.mb-substr.php

    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mbedtls握手返回-7200
  • ¥30 c++ http服务器
  • ¥15 express连接mssql,每条额外附加了语句
  • ¥20 IQOO12如何有效ADB方法
  • ¥15 ios如何获取用户的订阅情况
  • ¥15 复杂表达式求值程序里的函数优先级问题
  • ¥15 求密码学的客成社记ji着用
  • ¥35 POI导入树状结构excle
  • ¥15 初学者c语言题目解答
  • ¥15 div editable中的光标问题