PHP Shorten String Function

Today, We want to share with you PHP Shorten String Function.In this post we will show you php string functions, hear for php string length we will give you demo and example for implement.In this post, we will learn about php trim spaces before and after with an example.

PHP Shorten String Function

There are the Following The simple About PHP Shorten String Function Full Information With Example and source code.

Read Also:  How to get the browser viewport height and width dimensions?

As I will cover this Post with live Working example to develop php trim string, so the some php rtrim, ltrim in php for this example is following below.

function convertShotString($data, $length, $endCharData = '…') {
    
    if (is_string($data) === false) {
     
        return false;
        
    }

    if (mb_strlen($data) > $length) {

        return mb_substr($data, 0, ($length - mb_strlen($endCharData))) . $endCharData;

    } else {

        return $data;

    }

}

echo convertShotString('This is more text to pakainfo the website with.', 20); // This is more text t…
echo convertShotString('This is more text to pakainfo the website with.', 20, '...'); // This is more text t...
echo convertShotString('Pakainfo.', 20); // Pakainfo.
echo convertShotString('Pakainfo.', []); // Returns false

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  Remove Last Character from String in PHP

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Shorten String Function.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel Check Duplicate Records before insert
  2. Read Also:  Simple Hello World Example using Angular
  3. Read Also:  jQuery Capture Webcam Image Using Web Camera in PHP
  4. Read Also:  Angular 9/8 Get Selected DropDown Value on Form Submit
  5. Read Also:  What the difference is between a URI and a URL?
  6. Read Also:  How to Convert String to array in php Examples
  7. Read Also:  How to Find The Total Number of Products in WP REST API v3?
  8. Read Also:  Angular 9/8 Select Dropdown | Get Selected DropDown Value on Change Event
  9. Read Also:  PHP String Explode and Implode Function
  10. Read Also:  jquery tabs refresh active tab on page reload
CLOSEX