Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to limit word in php

//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>
 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #limit #word #php
ADD COMMENT
Topic
Name
3+7 =