quick php q
- Started
- Last post
- 5 Responses
- kinetic
im trying to replace characteres in a string if it is longer than a certain length.
how would i change say, the 13th 14th and 15th characteres to ... respectively?
i cant find any function that replaces characters based on their numerical position in a string (like you would in flash)
thanks for help on this..im stumped!
cheers
- arlo0
This is what I use to shorten URLs into ending with '...' if they are too long:
if(strlen($row['referrer']) > 35){
$newURL = substr($row['referrer'], 0,40) . "...";
} else {
$newURL = $row['referrer'];
}
- REINVIGORATE0
If you want what's longer then the desired length truncated use this nifty function I wrote. I use it in a lot of my stuff-
function strchk($str,$len)
{
if (strlen($str) > $len)
return substr($str,0,$len) . "..";return $str;
}
- kinetic0
beautiful, thanks guys!
shawn..good to see you on NT man. i love reinvigorate :)
- REINVIGORATE0
thankya =)
- Phenyl230
"i cant find any function that replaces characters based on their numerical position in a string"
for future reference:
substr_replace