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);
//actually there is lots of way to do that , here I want to tell you two ways that actully worked for me and my friend
//solution 1
function limit_words($string, $word_limit)
{
$words = explode(" ",$string);
return implode(" ",array_splice($words,0,$word_limit));
}
//code like this in your html
<span>
<?php echo limit_words($post['content'],14 ). ' ....'; ?>
</span>
//solution 2
//simply code like this in your php and html
<th scope="row"><p style="background: none; text-align: center; margin-top: 25px"><?= substr($row['flink'],2 ?></p>
</th>
echo str_word_count("word count function");