Thinkphp 内置字符串截取函数

8
145

ThinkPHP有一个内置字符截取函数msubstr()如下:

  1. msubstr($str, $start=0, $length, $charset=”utf-8″, $suffix=true)
  2. $str:要截取的字符串
  3. $start=0:开始位置,默认从0开始
  4. $length:截取长度
  5. $charset=”utf-8″:字符编码,默认UTF-8
  6. $suffix=true:是否在截取后的字符后面显示省略号,默认true显示,false为不显示

调用如下

  1. {$vo.title|msubstr=5,5,’utf-8′,false}

解释:截取字符串$vo.title,从第5个字符开始,截取5个,编码为UTF-8,不显示省略号

8 COMMENTS

  1. I am actually delighted to read this weblog posts which carries lots of valuable facts, thanks for
    providing these kinds of information.

  2. Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is important and everything.
    But just imagine if you added some great photos or videos to give your posts more, “pop”!
    Your content is excellent but with pics and clips,
    this website could certainly be one of the most beneficial in its field.

    Awesome blog!

  3. Fantastic site. A lot of useful information here. I’m sending it to some buddies
    ans also sharing in delicious. And certainly, thanks on your
    effort!

  4. facebook find love –
    It is actually a great and helpful piece of info. I’m happy that you
    simply shared this helpful info with us.
    Please keep us informed like this. Thanks for sharing.

  5. Excellent items from you, man. I have bear in mind your stuff prior to
    and you are just extremely wonderful. I actually like what you’ve
    got right here, certainly like what you’re stating
    and the best way in which you assert it. You are making it entertaining and
    you still take care of to stay it wise. I can not wait to learn far more
    from you. This is really a wonderful web site.

  6. I’m amazed, I must say. Rarely do I encounter a blog that’s both educative and
    amusing, and let me tell you, you’ve hit the nail on the
    head. The issue is something that too few men and women are
    speaking intelligently about. I am very happy I found this during my search for something concerning this.

LEAVE A REPLY

Please enter your comment!
Please enter your name here