PHP » GoLang |
login |
register |
about
|
Just convert it to a slice of runes first, slice, then convert the result back:
str:="абвгд" // get 3 first string([]rune(str)[:3]) //returns абв // get from 1 (included) to 4 (not included) fmt.Println(string([]rune(str)[1:4])) // returns бвг mb_substr(PHP 4 >= 4.0.6, PHP 5, PHP 7) mb_substr — Get part of string Description
string mb_substr
( string
$str
, int $start
[, int $length = NULL
[, string $encoding = mb_internal_encoding()
]] )
Performs a multi-byte safe
substr() operation based on
number of characters. Position is
counted from the beginning of
Parameters
Return Values
mb_substr() returns the portion of
Changelog
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|