PHP mb_substr mbstring function

Definition and Usage

mb_substr  - Get string portion

Version Support

PHP4 PHP5 PHP7
stand by stand by stand by
5.4.8 length pass NULL, extracted from the start to the end of the string. In previous versions, NULL will be treated as 0 to deal with.

grammar

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

  mb_substr ()  number of characters performed according to a multi-byte safe  substr ()  operation. The position is counted from a start position of str. The position of the first character is 0. Position of the second character is 1, and so on.

parameter

parameter Necessary description
str Yes Extracting sub-string from the string.
start Yes If the start is not negative, the string will be returned from the location of the start of str, counting from zero. For example, the string 'abcdef', the character position 0 is 'a', the character at position 2 is 'c', and so on. If start is negative, the returned string str from the start at the end of the first character to start.
length Yes The maximum number of characters in str to use. If this parameter is omitted or introduced to NULL, the end of the string will be extracted.
encoding no

encoding parameter is the character code. If omitted, the internal character encoding.

return value

Str function returns the designated part according to the start and length parameters.

Examples

echo mb_substr("hello world",2,3); 

  

Related Pages

mb_strcut ()  acquired as part of the character -
mb_internal_encoding ()  - Set / Get internal character encoding

Guess you like

Origin www.cnblogs.com/jc2182/p/12145253.html