PHP: mb_strcut - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mb_strimwidth mb_split

Last updated: Fri, 26 Jan 2007

view this page in

# mb_strcut

(PHP 4 >= 4.0.6, PHP 5)

mb_strcut -- Get part of string

## Description

string mb_strcut ( string str, int start [, int length [, string encoding]] )

mb_strcut() returns the portion of `str` specified by the `start` and `length` parameters.

mb_strcut() performs equivalent operation as mb_substr() with different method. If `start` position is multi-byte character's second byte or larger, it starts from first byte of multi-byte character.

It subtracts string from `str` that is shorter than `length` AND character that is not part of multi-byte string or not being middle of shift sequence.

`encoding` is character encoding. If it is not set, internal character encoding is used.

See also mb_substr(), mb_internal_encoding().

add a note User Contributed Notes
mb_strcut
t dot starling at physics dot unimelb dot edu dot au
27-Aug-2004 04:01
`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.`
oyag02 at yahoo dot co dot jp
26-Sep-2003 03: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`
add a note
mb_strimwidth mb_split

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST