function send($message,$mobile,$sender)
{
$url=file_get_contents("http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.comm);
//????
}
网址的结果是: 错误:0 消息ID:1302490
1-我怎样才能获得错误和值的值? msgid来自函数的结果?
function getDelivery($msgid)
{
$url=file_get_contents("http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com);
// ????
}
网址的结果是: STATUS05:消息已成功发送...
2-如何从函数的结果中仅获取状态值(01 02 03 04 05)?
答案 0 :(得分:0)
第一种方式,使用preg_match_all
,然后浏览$array
并提取所有数字:
$string='Error : 0 MessageID : 1302490';
preg_match_all('/[0-9]*/', $string, $array);
print_r($array);
第二种方式,如果你的字符串总是具有相同的结构并且永远不会改变:
$string='Error : 0 MessageID : 1302490';
$string_array=explode("MessageID : ", $string);
$error_string=$string_array[0];
$error=(int)str_replace('Error : ', '', $error_string);
$messageId=(int)$string_array[1];
echo $error.' '.$messageId;
我希望这有助于你获得一个起点。