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 7901699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:17:40+00:00 2026-06-03T09:17:40+00:00

Example of a $text variable: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed

  • 0

Example of a $text variable:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Splitting it in half:

$half = strlen($text) / 2;

will get me to the o character in consequat.

How can I find the position of the nearest sentence delimiter (dot) in the middle of the text? In this example it’s 7 characters after that o.

Also this text contains HTML code.
I want to ignore the HTML when finding out the half-point of the text, and ignore dots from within html attributes etc.

  • 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-03T09:17:42+00:00Added an answer on June 3, 2026 at 9:17 am

    Take a look at substr, strip_tags and strpos. With the help of strpos you find the position of the next dot and with strip_tags you strip all the html tags from the string.

    $string = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborumt.';
    $string = strip_tags($string);
    $half = intval(strlen($string)/2);
    echo substr($string, 0, strpos($string, '.', $half)+1);
    

    Consider that you have to make sure a dot exists after the value of $half or else the output is not going to be what you desire.

    Perhaps something like this?

    if (strpos($string, '.', $half) !== false)
        echo substr($string, 0, strpos($string, '.', $half)+1);
    else
        echo substr($string, 0, $half) . '...';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Supposing I have the following text: Lorem ipsum dolor sit amet, consectetur adipisicing elit,
I have a JavaScript variable similar to: a_name_string: RT @<a href=http://twitter.com/SomethinG>SomethinG</a>: Lorem ipsum dolor
I have a JavaScript variable: var text = http://example.com Text can be multiple links.
I want to replace space with tab in a text variable. For example something
Can anybody help me with retrieving some elements from the following example text: sdfaasdflj
<div class=example>Some example text</div> <div class=example>Some more example text</div> How can I remove all
I have a string for example like :)text :)text:) :-) word :-( i need
Example I: if (textField.text = @0, @1, @2, @3, @4, @5, @6, @7, @8,
for example : I want to remove all highlighted tags alt text http://shup.com/Shup/299976/110220132930-My-Desktop.png
The following jQuery example should put some text into the div, but it doesn't.

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.