zoukankan      html  css  js  c++  java
  • mb_strcut与mb_substr()

    mb_strcut

    (PHP 4 >= 4.0.6, PHP 5, PHP 7)

    mb_strcut — 获取字符的一部分

    说明

    string mb_strcut ( string $str , int $start [, int $length = NULL [, string $encoding = mb_internal_encoding() ]] )

    mb_strcut()mb_substr() 类似,都是从字符串中提取子字符串,但是按字节数来执行,而不是字符个数。 如果截断位置位于多字节字符两个字节的中间,将于该字符的第一个字节开始执行。 这也是和 substr() 函数的不同之处,后者简单地将字符串在字节之间截断,这将导致一个畸形的字节序列。

    参数

     

    str

    要截断的 string

    start

    如果 start 不是负数,返回的字符串会从 str 的第 start 字节位置开始,从 0 开始计数。举个例子,字符串 'abcdef',字节位置 0 的字符是 'a',字节位置 2 的字符是 'c',以此类推。

    如果 start 是负数,返回的字符串是从 str 末尾处第 start 个字节开始的。

    length

    字节长度。If omitted or NULL is passed, extract all bytes to the end of the string.

    encoding

    encoding 参数为字符编码。如果省略,则使用内部字符编码。

    返回值

    mb_strcut() 根据 startlength 参数返回 str 的一部分

  • 相关阅读:
    Java数组的内存结构
    2014.11.9--最近的小感悟
    十一两天感悟
    Are you happiness
    Are you busy?
    Lesson 81-82 Are they true
    Lesson 79-80 People are getting sick
    Lesson 77-78 Socially Discriminated Against
    Lesson 75-76 Shopping on the web
    更新单点,求区间—— luogu 3374
  • 原文地址:https://www.cnblogs.com/dsboy/p/6655023.html
Copyright © 2011-2022 走看看