Can someone help me with a simple php function?
I have an area that will only fit 13 characters.
So if the string I want to put in there is longer than 13 characters I want to chop it down to 10 and add ...
Example:
Hello My Name Is Greg ->becomes-> Hello My N...
Thanks!
Limit a string to 13 charcters...
Moderator: General Moderators
Re: Limit a string to 13 charcters...
Code: Select all
if(strlen($string) > 13)
$string = substr($string, 0, 10);Re: Limit a string to 13 charcters...
ahhhh substr... perfect. Thank you!
Here is my final function (updated):
Here is my final function (updated):
Code: Select all
function MakeItFit($string,$chars){
if(strlen($string) > $chars){
$string = substr($string, 0, $chars -3);
$string .= '...';
}
return $string;
}