I am trying to optimize increase the speed of this loop. I would like it if anyone has any ideas to boost the speed as there is thousands of members and it does take time time to complete currently
SQL Stored PROCEDURE MembersMobileByVenue returns this-> Example
FirstName Phone Venue
Aaron 04******* 7272CD46D51F
Brad 04******* CF105BB0
Adam 04******* 7272CD46D51F
Craig 04******* CF105BB0
PHP
$venueIDS = isset($_POST['location']) ? $_POST['location'] : array();
$msg = $_POST['message'];
$response = array();
if(!empty($venueIDS)){
$Members = GoldCardMembers::MembersMobileByVenue();
foreach($Members as $Member){
if(in_array($Member->Venue, $venueIDS)){
$destination = $Member->Phone;
$text = 'Hi ' . $Member->FirstName . ' ' .$msg. '. Reply STOP to opt out';
$ref = 'Members';
$content = '&to='.rawurlencode($destination).
'&message='.rawurlencode($text).
'&ref='.rawurlencode($ref);
$smsbroadcast_response = sendSMS($content);
$response_lines = explode("
", $smsbroadcast_response);
foreach( $response_lines as $data_line){
$message_data = "";
$message_data = explode(':',$data_line);
if($message_data[0] == "OK"){
array_push($response, "The message to ".$message_data[1]." was successful, with reference ".$message_data[2]."
");
}elseif( $message_data[0] == "BAD" ){
array_push($response, "The message to ".$message_data[1]." was NOT successful. Reason: ".$message_data[2]."
");
}elseif( $message_data[0] == "ERROR" ){
array_push($response, "There was an error with this request. Reason: ".$message_data[1]."
");
}
}
}
}
}
foreach($response as $message){
echo $message;
}