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've been working on a project that can't be described as 'small' anymore (40+
I'm working on a small UML editor project, in Java, that I started a
I'm working on a small project that displays answers for a survey. I'm having
Im working on a small graphics engine project that and I want to it
I'm working on a small lucene project, where i have to index a bunch
I am working in a small educational project where we have to implement a
I'm working on a small project to help me tag content on Flickr. I've
I'm working on a small project in VB.Net where I get a input from
I'm currently working on a small project with OCaml; a simple mathematical expression simplifier.
I'm trying to learn GNUMake for a small project I'm working on. So far,

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.