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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:44:37+00:00 2026-06-08T00:44:37+00:00

I want description, resolution and additional_notes to get cut off when it gets longer

  • 0

I want description, resolution and additional_notes to get cut off when it gets longer than 6 words and then have the “…” with a link to “see full case”. I only want this to show on the fields that got cut off, not the ones that are less than 6 words because the full field would already be showing. If you guys could please help me figure out how to do this it would make my day! thank you!

I have this query which so far only works to get the field to cut off at 6 words:

$sql = ("SELECT id, sso, case_status, assigned_to, updated, created, SUBSTRING_INDEX(additional_notes,' ',6) as additional_notes, SUBSTRING_INDEX(resolution,' ',6) as resolution, SUBSTRING_INDEX(description,' ',6) as description FROM rmstable2 WHERE sso LIKE '%{$sso}%'");

The results show up in a table sort of like this:

Description: php here
Resolution: php here
Additional Notes: php here
and so on…

  • 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-08T00:44:39+00:00Added an answer on June 8, 2026 at 12:44 am

    How about this:

    <?php
    
    $text = array(
        'some long texts with multiple words, more then seven',
        'some long texts with multiple words, more then seven',
        'some long texts with multiple words, more then seven'
    );
    
    $new_text = array();
    foreach ( $text as $key => $string ) {
        $words = explode( ' ', $string );
        for ( $k=0; $k<6; $k++ ) {
            if ( $words[ $k ] ) $new_text[ $key ] .= $words[ $k ] . ' ';
        }
        $new_text[ $key ] .= '...';
        # Or like this, if you don't need the space
        //$new_text[ $key ] = rtrim( $new_text[ $key ] ) . '...';
    
    }
    print_r( $new_text );
    
    ?>
    

    Output:

    Array
    (
        [0] => some long texts with multiple words, ...
        [1] => some long texts with multiple words, ...
        [2] => some long texts with multiple words, ...
    )
    

    Or a CSS way:

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 200px;
    

    Hope that helps.

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

Sidebar

Related Questions

I want to get the Name and Description in the center of the columns..
See here http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx - for want of a better description - the statement block
I have a .csv file with code and description. I want to search the
I have a list, that has three fields: Title, PublishingRollupImage and Description. I want
I set description as field in solr.. Now i want to get description by
How can I make My iPhone Application's Installation Link ? Description : I want
I have the following columns in a table: Product Name Quantity Description I want
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
I want to retrieve the pure text (without any HTML) of the description of
this table i want to create job_id dynamic Jobs Title text Job Description text

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.