Home » » Display limited characters from text

Display limited characters from text

Written By Unknown on Selasa, 08 Februari 2011 | 21.39

Hi friends !! It is the function to display limited characters from a string without cutting the last word. If we use only substr the last word is not displayed properly. Using this custom function, we can solve this.

We just have to pass the string and the limit to the function. It will return the result string. Thanks !!

  function showstring($string,$pos){
$data=substr($string,$pos,1);
if($data!=" "){
while($data!=" "){
@$pos=$pos+1;
$data=substr($string,$pos,1);
}
}
$data=substr($string,0,$pos);
echo $data;
}


Call function like this : -
echo showstring('This is a little blog of php functions and source codes',30);
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger