我有一个短信的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>
现在我想向多个号码发送短信有了这个,我可以一次发送到一个号码有人能在这件事上帮我吗
您可以添加更多的输入(或循环输入)并将名称设置为数组。
<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
我已经解决了问题
$麻木=$_POST['to']$tos=preg_replace('#''s+#',','、trim($麻木));用这行^_^
$to="$tos";