If you want to show some content in large content. For that this code will help you...
<?php
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]) . '....<a href="" >Read More</a>';
}
return $text;
}
$str = "My Name is Karda Ji. I am From India . India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country. India is a greate Country.";
echo limit_text($str,30); //30 is number after that read more is visible
No comments:
Post a Comment