我有短信api
<?php
// Configuration variables
$type = "xml";
$id = "92300xxxxxxx";
$pass = "xxxxxxxxxxxx";
$lang = "English";
$mask = "Outreach";
// Data for text message
$to = "$_POST['to']";
$message = "$_POST['message']";
// Prepare data for POST request
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=".$lang."&mask=".$mask."&type=".$type;
// Send the POST request with cURL
$ch = curl_init('http://www.outreach.pk/api/sendsms.php/sendsms/url'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); //This is the result from Outreach curl_close($ch);
?>
现在我制作表格
<form method="post">
<input type="text" name="message">
<input type="text" name="to"> --->contact number list
</form>
现在我想将短信发送给多个号码 有了这个,我可以一次发送到一个号码 任何人都可以帮助我解决这个问题
答案 0 :(得分:0)
您可以添加更多输入(或循环)并将名称设置为数组。
<input type="text" name="to[]" />
<input type="text" name="to[]" />
<input type="text" name="to[]" />
通过循环遍历数组
来访问它foreach( $_POST['to'] as $key => $val ) {
echo 'send to ' . $val .'<br />';
}
//code not tested
答案 1 :(得分:0)
我已经解决了这个问题
$ numb = $ _POST ['to'] $ tos = preg_replace('#\ s +#',',',trim($ numb));用这一行^ _ ^
$ to =“$ tos”;