Saturday 23 August 2014

Read More option in large content..

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

?>