[PHP 7 >= 7.4.0, PHP 8]
mb_str_split — Given a multibyte string, return an array of its characters
Description
mb_str_split[string $string
, int $length
= 1, ?string
$encoding
= null
]: array
Parameters
string
The string to split into characters or chunks.
length
If specified, each element of the returned array will be composed of multiple characters instead of a single character.
encoding
The encoding
parameter is the character encoding.
If it is omitted or null
, the internal character encoding value will be used.
A string specifying one of the supported encodings.
Return Values
mb_str_split[] returns an array of strings.
Changelog
8.0.0 | encoding is nullable now.
|
8.0.0 | This function no longer returns false on failure.
|
webmaster at redinfo dot co dot kr ¶
1 month ago
if[ !function_exists['mb_str_split']]{
function mb_str_split[ $string = '', $length = 1 , $encoding = null ]{
if[!empty[$string]]{
$split = array[];
$mb_strlen = mb_strlen[$string,$encoding];
for[$pi = 0; $pi < $mb_strlen; $pi += $length]{
$substr = mb_substr[$string, $pi,$length,$encoding];
if[ !empty[$substr]]{
$split[] = $substr;
}
}
}
return $split;
}
}
info at ensostudio dot ru ¶
1 year ago
Note: function return NULL if can't convert argument type.
Polyfill PHP < 7.4 based on package "symfony/polyfill-mbstring":