PHP Shorten String Function

php Programming

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.

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

Snippet Contents

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.

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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   How to exit a for loop or skip iteration in PHP
  2.   PHP String Explode and Implode Function
  3.   ng-keyup Event using Angular Example
  4.   Vue.js DatePicker Source Code Example with Demo
  5.   Vue Toggle Switch Component ON-OFF
  6.   PHP Stripe API ACH Payments using stripe.js
  7.   Remove Last Character from String in PHP
  8.   How to Convert String to array in php Examples
  9.   PHP Ajax Image Upload Resize Crop using jQuery
  10.   Eloquent Insert Multiple Records in Laravel

Leave a Reply

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