Ms7 Search
Google 搜尋 翻譯
calendar
« 九月 2024 »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
近期文章
文章分類
網站連結
Syndicate

« | »

php substr 秀中文字串問題

2010-08-12 @ 18:48 in PHP, JavaScript, Sql

在用 substr 秀中文字串時,常常因為 big5用 2 byte , utf8 用 3 byte,不知如何切,今天在網上找到方法,改用 mb_substr 就可以,需計算字數用mb_strlen

例如: 

mb_substr($content,0,15,"UTF-8");  mb_substr($content,0,15,"BIG-5");

mb_strlen($content,"UTF-8");  mb_strlen($content,"BIG-5");

參考:

http://blog.xuite.net/chenbruse/bruse/13351768

http://ms7.fhsh.tp.edu.tw/php5c/ref.mbstring.html

 

 

迴響

php substr 秀中文字串問題 | 豬窩

Have you ever thought about creating an ebook or guest authoring on other blogs?
I have a blog based upon on the same ideas you discuss and would really like to have you share some stories/information. I
know my audience would appreciate your work. If you are even remotely interested, feel free to shoot me an email.

作者 best website hosting @ 17:44, 2020-08-14
«上一篇   1 2 3 4 5
發表迴響
 authimage