读取PDO PHP中的excle和csv文件以发送SMS

我想通过上传excelsheet或csv文件来发送消息,文件中将包含手机号码,这种方法我们用来发送批量和沉重捆绑包。下面是我的代码可以在其中提取文件数据的代码,我还希望make变量也可以帮助我发送动态内容,但我不知道该怎么做。

我要实现的目标

  1. 当我上传excel时,它会获取所有列名,并在“下拉列表”文本框中显示该名称
  2. 我选择一个用于手机号码的下拉列表
  3. 并使用Variable

EXCEL喜欢

|---------------------|
|  Name    | Mobile   |
|---------------------|
|  John    | 999999   |
|  Cartor  | 999999   |
|  Thomas  | 999999   |
----------------------|

Dropdown box option will be like:
   Name 
   Mobile

**SMS Code**
$curl = curl_init();
curl_setopt_array($curl,array(
CURLOPT_URL => "https://api.msg91.com/api/sendhttp.php?campaign=&response=&afterminutes=&schtime=&flash=&unicode=&mobiles=Mobile%20no.&authkey=%24authentication_key&route=4&sender=TESTIN&message=Hello!%20This%20is%20a%20test%20message&country=91",CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => "",CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 30,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => "GET",CURLOPT_SSL_VERIFYHOST => 0,CURLOPT_SSL_VERIFYPEER => 0,));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
<?php
   if (isset($_POST['Submit'])) {
   $file = $_POST['testcsv'];
   $columnheadings = false;
   $delimiter = ',';
   $enclosure = "\"";
   $row = 1;
   $rows = array();
   $handle = fopen($file,'r');
   while (($data = fgetcsv($handle,1000,$delimiter,$enclosure)) !== FALSE) {

   if (!($columnheadings == false) && ($row == 1)) {
      $headingTexts = $data;
   } 
   elseif (!($columnheadings == false)) {
      foreach ($data as $key => $value) {
      unset($data[$key]);
      $data[$headingTexts[$key]] = $value;
   }
      $rows[] = $data;
   } 
   else {
      $rows[] = $data;
   }
  }

 fclose($handle);
 //var_dump($rows); // It will print complete CSV data
 echo "<pre>";
 print_r($rows);
 echo "</pre>";
 }
?>

<!DOCTYPE html>
<html>
    <head>
        <title>CSV</title>
    </head>
    <body>
        <div style="margin: 30px 10%;">
            <h3>CSV form</h3>
            <form id="myform" action="" method="post">
                <input type="file" name="testcsv" />
                 <select name="selectYourVariable">
                    <option name="name">Name</option>
                    <option name="mobile">Mobile</option>
                 </select>
                <textarea name="message" col="5" row="5"> </teaxtarea>
                <input type="Submit" name="Submit" />
                <br />
            </form>
        </div>
    </body>
</html>

我的消息将如下:Hello $ varibale [name],你好吗? stackoverflow开发人员帮助我实现了此功能。

并将此消息发送到John,thomas with name

an_day 回答:读取PDO PHP中的excle和csv文件以发送SMS

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169282.html

大家都在问