Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php description limit

// strip tags to avoid breaking any html
$string = strip_tags($string);
if (strlen($string) > 500) {

    // truncate string
    $stringCut = substr($string, 0, 500);
    $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 .= '... <a href="/this/story">Read More</a>';
}
echo $string;
Comment

PREVIOUS NEXT
Code Example
Php :: how naming resource routes laravel 
Php :: Generate Unique Random String With Any Character Size | unique random php generator | php unique id generator 
Php :: laravel make model with migration 5.8 
Php :: remove special characters in php 
Php :: phpmyadmin 403 forbidden centos 6 
Php :: create multiple session in php 
Php :: livewire datatable Delete column momentarily triggering confirmation dialog of last row during page load 
Php :: laravel realation with has 
Php :: model hasmany laravel 
Php :: shortcode in wp 
Php :: add javascript to functions.php 
Php :: what does defined do in php 
Php :: axios post not sending data php 
Php :: move_uploaded_file 
Php :: php artisan make :migration with model 
Php :: laravel 8 register with email verification 
Php :: laravel echo html 
Php :: update values in array in php 
Php :: laravel count distance lat/longtidue 
Php :: delete and return response and nocontent laravel 
Php :: php assign if not null 
Php :: laravel route optional parameter 
Php :: unset php return array 
Php :: file_get_content 
Php :: php append n time pattern to string 
Php :: How to add custom button in wordpress admin section 
Php :: $_SESSION php example 
Php :: if exists in string count php 
Php :: get pages with template wp php 
Php :: export mysql data to word in php 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =