Return full string (without broken last word)
No Comments Yet so far
Leave a comment
October 4, 2008, 5:36 pm
Filed under: Useful PHP Functions | Tags: full string, php string function, return full words, return string php
Filed under: Useful PHP Functions | Tags: full string, php string function, return full words, return string php
This function will return you substring of any number of characters without broken last word. Very useful function and easy to extend as you need.
function StringWithFullWords($MainString,$NoOrCharecter=10)
{
$Tmp=str_split($MainString,1);
for($I=0;$I$NoOrCharecter)
break;
if($Tmp[$I]==” “)
$LastSpacePos=$I;
}
return substr($MainString,0,$LastSpacePos);
}
Leave a Comment
No Comments Yet so far
Leave a comment
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>