php将一个字符串转换成数组,支持中文
//将一个字符串转换成数组,支持中文 function strToArray($string) { $strlen = mb_strlen($string); while ($strlen) { $array[] = mb_substr($string, 0, 1, "utf8"); $string = mb_substr($string, 1, $strlen, "utf8"); $strlen = mb_strlen($string); } return $array; } $string = '链接:www.ccvok.com 优惠券'; $arr = strToArray($string); print_r($arr); $topictitle="链接:www.5devip.com 雅爱笔记"; $length = mb_strlen($topictitle, 'utf-8'); $titlearray = []; for ($i=0; $i<$length; $i++) { $titlearray[] = mb_substr($topictitle, $i, 1, 'utf-8'); } print_r($titlearray);