Home > Article > Backend Development > How to convert Chinese character string to array in php
php method of converting Chinese character string to array: first create a PHP sample file; then define a Chinese character string; finally convert the Chinese character into an array through methods such as "mb_strlen($topictitle, 'utf-8');" Just convert the string into an array.
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
php How to convert a Chinese character string into an array?
php Convert Chinese character string to array[]
Code:
$topictitle="沙漠骆驼"; $length = mb_strlen($topictitle, 'utf-8'); $titlearray = []; for ($i=0; $i<$length; $i++) { $titlearray[] = mb_substr($topictitle, $i, 1, 'utf-8'); } return $titlearray;
Effect:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert Chinese character string to array in php. For more information, please follow other related articles on the PHP Chinese website!