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 秀中文字串問題 | 豬窩
Do you mind if I quote a couple of your posts as
long as I provide credit and sources back to your weblog? My blog is in the very same niche as yours and my users would truly benefit from a
lot of the information you present here. Please let me know if this
alright with you. Appreciate it!
php substr 秀中文字串問題 | 豬窩
There's definately a great deal to know about this issue.
I really like all of the points you've made.
php substr 秀中文字串問題 | 豬窩
Its like you read my mind! You appear to know so much approximately this, like you wrote the
guide in it or something. I think that you simply could
do with a few % to power the message home a little bit, however instead of that, this is fantastic blog.
A fantastic read. I will certainly be back.
php substr 秀中文字串問題 | 豬窩
It's a shame you don't have a donate button! I'd without a
doubt donate to this fantastic blog! I guess for now i'll settle
for book-marking and adding your RSS feed to my Google account.
I look forward to new updates and will share this website with my Facebook group.
Chat soon!
php substr 秀中文字串問題 | 豬窩
I know this if off topic but I'm looking into starting my own weblog and was wondering what
all is needed to get set up? I'm assuming having a
blog like yours would cost a pretty penny? I'm not very
internet smart so I'm not 100% sure. Any recommendations
or advice would be greatly appreciated. Kudos