note 99851 modified in function.mb-split by danbrown
| From: | danbrown@php.net | Date: | Fri, 10 Sep 2010 16:45:49 +0000 |
| Subject: | note 99851 modified in function.mb-split by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172451@lists.php.net to get a copy of this message | ||
In addition to Sezer Yalcin's tip.
This function splits a multibyte string into an array of characters. Comparable to str_split().
<?php
function mb_str_split( $string ) {
# Split at all position not after the start: ^
# and not before the end: $
return preg_split('/(?<!^)(?!$)/u', $string );
}
$string = 'ç«è½¦ç¥¨';
$charlist = mb_str_split( $string );
print_r( $charlist );
?>
# Prints:
Array
(
[0] => ç«
[1] => 车
[2] => 票
)
--was--
In addition to Sezer Yalcin's tip.
This function splits a multibyte string into an array of characters. Comparable to str_split().
<?php
function mb_str_split( $string ) {
# Split at all position not after the start: ^
# and not before the end: $
return preg_split('/(?<!^)(?!$)/u', $string );
}
$string = 'ç«è½¦ç¥¨';
$charlist = mb_str_split( $string );
print_r( $charlist );
# Prints:
Array
(
[0] => ç«
[1] => 车
[2] => 票
)
http://php.net/manual/en/function.mb-split.php