PHP 支持中文按固定长度分割字符串 适用于imagettftext

';
	}
	echo $str;
*/

	function str_split_unicode($str, $l = 0) {
		if ($l > 0) {
			$ret = array();
			$len = mb_strlen($str,"UTF-8");
			for ($i = 0; $i < $len; $i += $l) {
				$ret[] = mb_substr($str, $i, $l,"UTF-8");
			}
			return $ret;
		}
		return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
	}



使用原文地址:http://www.jb51.net/article/66214.htm


你可能感兴趣的:(php)