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.

Also Read :  PHP Google reCAPTCHA Validation Before Submit

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 :

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.

Leave a Reply

avatar
  Subscribe  
Notify of