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

  • Home
  • SEARCH
  • 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 8602131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:00:26+00:00 2026-06-12T02:00:26+00:00

I need to split text into two parts which this function does but it

  • 0

I need to split text into two parts which this function does but it cuts off in the middle of a word, I need it to work out the start or end of a word give or take a few characters.

I cannot base it on word count as I need the character range to be no more than 130 characters.

$str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem     Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown     printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum"

$first125 = substr($str, 0, 125);
$theRest = substr($str, 125);

Thanks

  • 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-06-12T02:00:27+00:00Added an answer on June 12, 2026 at 2:00 am

    Here’s a very basic solution to what you’re trying to do to get you started

    $first125 = substr($str, 0, 125);
    $theRest = substr($str, 125);
    
    $remainder_pieces = explode(" ", $theRest, 2);
    
    $first125 .= $remainder_pieces[0];
    $theRest = $remainder_pieces[1];
    
    echo $first125."</br>";
    echo $theRest;
    

    but there are more things to consider, for example with that solution, if the 125th character is a space after a word ends, it’ll include another word beyond that, so you might want to add some additional checking methods to try and make it as accurate as possible.

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

Sidebar

Related Questions

Hi i'm using the strtok function to split a sentence into two parts. I
I have text file with some text information and i need to split this
I'm trying to split up a string into two parts using regex. The string
I need to split a string (in Java) into individual words ... but I
I have a large string (with text). I need to split it into a
I need to split a big chunk of text into paragraphs of the same
I need split string by commas and spaces, but ignore the inside quotes, single
I need to split a keyword string and turn it into a comma delimited
I need to split an flv file into chunks of the known size on
I need to split my string input into an array at the commas. Is

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.