+88 01797-506292

Post Date: November 16, 2017
Posted By: admin

Make text limit

function limit_text($text, $limit=15) {

    if (str_word_count($text, 0) > $limit) {
        $words = str_word_count($text, 2);
        $pos = array_keys($words);
        $text = substr($text, 0, $pos[$limit]) . '... <a href="#" data-toggle="tooltip" title="'.$text.'"><i class="fa fa-info fa-1"></i></a>' ;
    }
    return $text;
}

echo limit_text('test asdf', 1);


Leave a Reply

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