Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php limit string length

if (strlen($str) > 10)
   $str = substr($str, 0, 7) . '...';
Comment

limit text length in php

// limit text length in php and provide 'Read more' link
    function read_more($string)
    {
      // strip tags to avoid breaking any html
        $string = strip_tags($string);
        if (strlen($string) > 35) {

            // truncate string
            $stringCut = substr($string, 0, 35);
            $endPoint = strrpos($stringCut, ' ');

            //if the string doesn't contain any space then it will cut without word basis.
            $string = $endPoint? substr($stringCut, 0, $endPoint) : substr($stringCut, 0);
            $string .= '...';
        }
        return $string;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: turn on php errors 
Php :: switching inter php 
Php :: __construct 
Php :: findorfail laravel 
Php :: php header refresh 
Php :: php reading a file line by line 
Php :: php if no imagee exists 
Php :: array to string separated by comma php 
Php :: composer install without dependencies 
Php :: laravel 8 db like query 
Php :: laravel migation error 
Php :: create laravel project specific version 
Php :: wordpress the loop 
Php :: php convert bytes to mb 
Php :: laravel request all except 
Php :: laravel uppercase first letter 
Php :: php explode trim 
Php :: php average from array 
Php :: php delay 
Php :: select join distinct 
Php :: php form action self 
Php :: wp custom rest endpoint 
Php :: laravel check if object empty 
Php :: tmp cakephp name 
Php :: carbon add minutes 
Php :: php delete array item by value 
Php :: carbon minus 1 day 
Php :: select case default php 
Php :: using a php array in jquery 
Php :: How to Get the last element of an array in PHP – end() 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =