Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:42:16+00:00 2026-05-23T16:42:16+00:00

I am working on a small project that sends SMS Messages. I already have

  • 0

I am working on a small project that sends SMS Messages. I already have the message classes written, and ready to send back in the correct format.

However, I am having a technical design issue. I’m sure it is easily solved, but I haven’t come across this issue before so I am lost in the dark.

When I return a message longer than 160 chars, it obviously needs broken down into smaller messages and sent individually. My first thoughts are obviously to get the string length, then divide it by 160 chars, and round up to the greatest whole number (since you cannot send 2.5 messages,only 3) and then each sms needs to have 1/3, 2/3, 3/3 etc in the message as well showing the user which order to read them in. (trust me, they will need it)

My thoughts are obviously using some kind of loop to create a ‘new ServiceMessage()’ for each 160 char message. But I am unsure exactly how to do it, as well as unsure how to show the count of message (1/2, 2/3, etc).

Fairly simple, I am sure, but this is my first shot at it – so any help is greatly appreciated! Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:42:17+00:00Added an answer on May 23, 2026 at 4:42 pm
    $messages = str_split($message , 160);
    foreach($messages as $message){
       // send $message
    }
    

    A more complicated version with the number of message itself can be like this, the code is untested:

    if(strlen($message) > 160){
        /// lets use 152 characters and keep room for message number like (1/10), 
        /// we can have upto 99 parts of the message (99/99)
    
        $messages = str_split($message , 152); 
        $how_many = count($messages);
        foreach($messages as $index => $message){
            $msg_number = ($index + 1);
            $message = "(".$msg_number."/".$how_many.") ".$message;
    
            // send $message
        }
    }
    else{
        // send $message
    }
    

    The above might waste 2 characters per message but it keeps the calculation rather simple.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small project that I will be working on shortly that collects
I have been working on a small project that is supposed to simulate a
I am working on a project that involves sending some very small encrypted messages
Noob here... :) I'm working on a small and personal project that is already
i'm working on a small project that might have an additional coder at some
I'm working on a small project that involves me loading an image into a
i am working on a small project that i need the ability to let
I'm working on a small django project that will be deployed in a servlet
I'm working on a small Java project that now connects to a MS SQL
I'm working with a very small sample project that can be downloaded from here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.