PHP截取发动短信内容的方法
废话不多说了,直接给大家贴代码了,具体代码如下所示:
$str_tmp = DAdmin_Utils::gbkStrSplit(“短信内容”, 700);//内容过长返回的是一个截取内容后的数组 700指的是截取的长度 $total = count($str_tmp); $num = 1; foreach($str_tmp as $str) { if($total > 1) { $str = $str . "{$num}/{$total}"; $num ++; } $sign = strtoupper(md5($key.$pMobile.$str.$ip)); $url = "短信地址?from=37&sgin=".$sign."&tel=".$pMobile."&msg=".$str; $ret = file_get_contents($url); $result = json_decode($ret,true); } //发送短信方法 function gbkStrSplit($string, $len = 1) { $length = strlen($string);//获取长度,汉字占三个字节 $retstr = ''; $retArr = array(); for ($i = 0; $i < $length; $i++) { $retstr .= ord($string[$i]) > 127 ? $string[$i] . $string[++$i] : $string[$i]; $len_tmp = strlen($retstr); if ($len_tmp >= $len) { $retArr[] = $retstr; $retstr = ''; } } if ($retstr != '') { $retArr[] = $retstr; } return $retArr; }
相关推荐
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28