Metin kısaltma fonksiyonumuzu aşağıda görebilirsiniz.
function kisalt($kelime, $str = 200)
{
if (strlen($kelime) > $str)
{
if (function_exists("mb_substr")) $kelime = mb_substr($kelime, 0, $str, "UTF-8").'...';
else $kelime = substr($kelime, 0, $str).'...';
}
return strip_tags($kelime);
}
Kullanımı aşağıdadır.
$cumle="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";
echo kisalt($cumle,80);
Ekran çıktısı aşağıdadır.
// Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem...