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.

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.

  Nested Queries Subqueries in SQL Example

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Download Project Scripts

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 :


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

  How to copy text to Clipboard using Vuejs

I hope you get an idea about PHP Shorten String Function.
I would like to have feedback on my 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.   Wordpress $wpdb Insert Multiple Records
  2.   PHP Webcam Capture Image Save from Camera using jQuery
  3.   Laravel 6 Eloquent Join Multiple Tables
  4.   Remove Last Character from String in PHP
  5.   How to Convert String to array in php Examples
  6.   PHP MySQL Dynamic SQL Insert Query
  7.   PHP String Explode and Implode Function
  8.   PHP Laravel Limit String Length (Truncate string) Example
  9.   Vue js Multiple Tag Input with Dynamic Autocomplete
  10.   Laravel 6 insert or update multiple records

Leave a Reply

Your email address will not be published. Required fields are marked *