Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php first 20 words

function limit_text($text, $limit) {
    if (str_word_count($text, 0) > $limit) {
        $words = str_word_count($text, 2);
        $pos   = array_keys($words);
        $text  = substr($text, 0, $pos[$limit]) . '...';
    }
    return $text;
}

echo limit_text('Hello here is a long sentence that will be truncated by the', 5);
Comment

PREVIOUS NEXT
Code Example
Php :: phpunit filter 
Php :: laravel forelse 
Php :: wpml language switcher shortcode 
Php :: email php using html 
Php :: laravel gigapay create payout 
Php :: make pagination wordpress admin panel 
Php :: how to increase request timeout in laravel 
Php :: php get prameter 
Php :: wordpress loop 
Php :: regex phpstorm 
Php :: php array continued 
Php :: DB::rollback() 
Php :: php array order by date 
Php :: get_posts term 
Php :: how to remove additional sidebar in magento 2 using xml 
Php :: generating-random-token-php 
Php :: get word between two characters php 
Php :: concat in laravel 8 
Php :: how to display array of img in wordpress 
Php :: mysql server has gone away php 
Php :: php see if undefined 
Php :: wordpress get user by id 
Php :: redirect from controller in laravel 
Php :: laravel meta csrf 
Php :: carbon to mysql datetime 
Php :: remove cookies php 
Php :: carbon add few hours 
Php :: how to disable register route in laravel 
Php :: mac os change the php verison 
Php :: php serverpath 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =