What the manual and the first commenter are trying to say is that mb_strcut uses byte offsets, as opposed to mb_substr which uses character offsets.
Both mb_strcut and mb_substr appear to treat negative and out-of-range offsets and lengths in the basically the same way as substr. An exception is that if start is too large, an empty string will be returned rather than FALSE. Testing indicates that mb_strcut first works out start and end byte offsets, then moves each offset left to the nearest character boundary.
mb_strcut
(PHP 4 >= 4.0.6, PHP 5)
mb_strcut — 文字列の一部を得る
説明
string mb_strcut
( string $str
, int $start
[, int $length
[, string $encoding
]] )
mb_strcut() は、mb_substr() と同じ処理を異なった方法で行います。位置 start がマルチバイト文字の 2 バイト目以降で ある場合、マルチバイト文字の最初のバイトから開始されます。
この関数は、length より短く、 かつマルチバイト文字列の一部でないかシフトシーケンスの中にない文字を 取りだします。
パラメータ
- str
-
取り出しの対象となる文字列。
- start
-
取り出しの開始位置。
- length
-
取り出す長さ。
- encoding
-
encoding パラメータには文字エンコーディングを指定します。省略した場合は、 内部文字エンコーディングを使用します。
返り値
mb_strcut() は、 start および length パラメータで指定した str の一部を返します。
mb_strcut
t dot starling at physics dot unimelb dot edu dot au
27-Aug-2004 08:01
27-Aug-2004 08:01
oyag02 at yahoo dot co dot jp
26-Sep-2003 07:53
26-Sep-2003 07:53
diffrence between mb_substr and mb_substr
example:
mb_strcut('I_ROHA', 1, 2) returns 'I_'. Treated as byte stream.
mb_substr('I_ROHA', 1, 2) returns 'ROHA' Treated as character stream.
# 'I_' 'RO' 'HA' means multi-byte character
