Questions:
PHP how to limit lines in a string?
How to fixed line in php?
How to fixed X line like facebook style?
Change text length in php and provide Read more link
Ans:
< ?PHP
//function start for line limit
function Lines($strs, $num=10) {
$lines = explode("\n", $strs);
$firsts = array_slice($lines, 0, $num);
return implode("\n", $firsts);
}
//function off
//$text = '......'
$text="line1
line2
line3
line4
line5
line6
";
$val = lines($text,4);//4 is limit line x
echo nl2br($val);//n2br for show lines
echo "..Read More";
? >