Question: I have been using the code below to send sms to customers telling them their account balances after a given period. so far the code is able to send sms to one person at a time. Can i modify the code to send the message to all customers.

```
<?php

function sendsms($sms_username,$sms_password,$sender_ID,$number,$message)
{
    if(isset($sms_username) && isset($sms_password))
    {
        $username = trim($sms_username);//your sms user account
        $password = trim($sms_password);//your sms password
        $type = '0';//FOR FLASH MESSAGES SET type to 1
        $dlr = '1';//request for delivery report
        $destination = $number;;//phone number 
        $source = urlencode($sender_ID);//This is the sender or label that will be received by client/user. MAXIMUM 11 CHARACTERS
        $message = urlencode("$message");//message content to be sent to user/client

        //Form url api
        $url = "https://api.sendingthesms/bulksms/?username=" .$username."&password=".$password."&type=0&dlr=1&destination=".$destination."&source=".$source."&message=" . $message;

        $scc = stream_context_create(array('http' => array('protocol_version' => 1.1)));//enforce http 1.1
        $response = file_get_contents("$url",0,$scc);//fire/call nalo sms api

        return $response;
    }else
    {
        return "username cannot be empty";
    }
}

echo sendsms("username","mypassword","$session_username",$mainphone3, $mysms);
header("location:index.php");
            exit;
?>

```

Answer: 
-First, you can change your if statement with the condition if your loop at the first character in the phrase and meets a space.

-Second, you can change how the way you swap from this :

```
  phrase[i] = temp;
  phrase[i] = phrase[j];
  phrase[j] = temp;

```

with this :

```
 temp = phrase[i];
 phrase[i] = phrase[j];
 phrase[j] = temp;

```
Here's the proper C++ way of doing it.

```
#include <iostream>
#include <string>
#include <sstream>

int main() {
    std::string phrase;

    std::cout << "Enter a phrase" << std::endl;
    getline(std::cin, phrase);

    std::stringstream ss{phrase};

    std::string reversedPhrase;
    std::string word;

    while (ss >> word) {
        std::swap(word[0], word[word.length() - 1]);
        reversedPhrase += word + " ";
    }

    std::cout << "Original phrase: " << phrase << std::endl;
    std::cout << "Reversed phrase: " << reversedPhrase << std::endl;
}

```

You can play around with the code live [here](https://wandbox.org/permlink/1Mjb46YY3uVbKCPk)