<?php

 
    function send_whatsapp_msg($number,$apikey, $msg, $file){

        $number_array = explode(',',$number);
        
        $msg_array= explode('###,',$msg);
        
        $file_array= explode(',',$file);
        
        // print_r($file_array);
        
        $api_key_array = explode(',',$apikey);
        
        foreach($number_array as $i => $f_number){
            
           
            
            if($i == 0)
            {
                
            }
            else
            {
                
                sleep(5);
                
            }
            
            
               $f_number;
              $f_msg =  $msg_array[$i];
              $f_file = $file_array[$i];
               
            //   echo $f_msg;
             
              // rawurlencode(
          
                $apikeynew = $api_key_array[$i];
                    
                $ch = curl_init();
                
                $url = 'http://api.textmebot.com/send.php?recipient='.$f_number.'&apikey='.$apikeynew.'&text='.$f_msg.'&file='.$f_file;
                
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                
                $response = curl_exec($ch);
            
                // if (curl_errno($ch)) {
                //     echo 'cURL error: ' . curl_error($ch);
                // } else {
                //       echo 1;
                // } 
            
              curl_close($ch);
            
            // echo 1;
        
        }
    }
?>