Home > Backend Development > PHP Tutorial > String segmentation problem with mixed Chinese and English numbers under PHP_PHP tutorial

String segmentation problem with mixed Chinese and English numbers under PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:39:06
Original
1062 people have browsed it

I spent some time searching online and found nothing.
Later I thought of a way, which I think is original.
Just use the interception and replacement function.

Copy code The code is as follows:

function smssubstr($string, $length) {
if(strlen($ string) <= $length) {
return $string;
}
$strcut = '';
for($i = 0; $i < $length; $i++) {
$strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
}
return $strcut;
}
for($i=1; $i<=$smsnum; $i++){
${'smscontent'.$i} = smssubstr($message,$smsper) ;
$message = str_replace(${'smscontent'.$i},"",$message);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321619.htmlTechArticleI spent some time searching online and found nothing. Later, I came up with a way, which I think is original. Just use the interception and replacement function. Copy the code The code is as follows: function smss...
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