Home > Backend Development > PHP Tutorial > php下关于中英数字混排的字符串分割问题_PHP

php下关于中英数字混排的字符串分割问题_PHP

WBOY
Release: 2016-06-01 12:19:43
Original
903 people have browsed it

在网上找了一点时间,发现都不怎样。
后来就自己想了个办法,算是原创吧。
只是用截取加替换的功能。
复制代码 代码如下:
function smssubstr($string, $length) {
if(strlen($string) return $string;
}
$strcut = '';
for($i = 0; $i $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
}
return $strcut;
}
for($i=1; $i${'smscontent'.$i} = smssubstr($message,$smsper);
$message = str_replace(${'smscontent'.$i},"",$message);
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template