I need your advice and help
i fetched an array of data from the database and i want to process each element one by one without using foreach loop, something like
pop element a and process it, when finished pop element b and process it, when finished pop element b and process it
until the array become empty then the script can exit
currently i`m looping through the data using foreach loop but things are not working find.
$loaded_message = $this->lib->load_queued_messages();
if(count($loaded_message) == 0) {
die ('Nothing to do');
}
foreach($loaded_message as $tosend)
{
if($this->lib->send_sms($tosend['from'], $tosend['msg'], explode(',', $tosend['numbers']), $tosend['owner'], $tosend['qid']))
{
// Remove the message from queue
$this->lib->remove_msg_from_queued_message($tosend['qid']);
$this->lib->log('message #' . $tosend['qid']. ' sent and removed from queue', $tosend['owner']);
}else{
$this->lib->log('SENDING_ERROR: message #' . $tosend['qid']. ' not sent and remain in the queue for#', $tosend['owner']);
}
}
Inside the log table i discovered that entry was made for wrong message id and it seems like message was sent to wrong number but it does not.