php substr 秀中文字串問題
在用 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.