Home  >  Article  >  Backend Development  >  php下关于中英数字混排的字符串分割问题_php技巧

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

WBOY
WBOYOriginal
2016-05-17 09:26:56998browse

在网上找了一点时间,发现都不怎样。
后来就自己想了个办法,算是原创吧。
只是用截取加替换的功能。

复制代码 代码如下:

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);
}
Statement:
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