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 — Get part of string
Beschreibung
$str
, int $start
[, int $length
[, string $encoding
]] )mb_strcut() extracts a substring from a string similarly to mb_substr(), but operates on bytes instead of characters. If the cut position happens to be between two bytes of a multi-byte character, the cut is performed starting from the first byte of that character. This is also the difference to the substr() function, which would simply cut the string between the bytes and thus result in a malformed byte sequence.
Parameter-Liste
-
str -
The string being cut.
-
start -
Starting position in bytes.
-
length -
Length in bytes.
-
encoding -
Der
encodingParameter legt das Zeichenencoding fest. Wird er nicht übergeben so wird das interne Zeichenencoding genutzt.
Rückgabewerte
mb_strcut() returns the portion of
str specified by the
start and
length parameters.
Siehe auch
- mb_substr() - Get part of string
- mb_internal_encoding() - Set/Get internal character encoding
mb_strcut
27-Aug-2004 01:01
26-Sep-2003 12: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