- Forums
- PHP
- How To Remove Long Repeated Letters In Words Comments
This Page Contains information about How To Remove Long Repeated Letters In Words Comments By wallpaperama in category PHP with 5 Replies. [1089], Last Updated: Sat May 18, 2024
wallpaperama
Fri Feb 15, 2008
5 Comments
486 Visits
today we had a task to edit all the comments from our users where they put comments such as:
you are soooooooooooooooooooooooooooooooooool coooollllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
as you can see, it just messes up because the word cool is so long that it goes beyond our webpage and it makes it look bad..
for quite some time now, i wanted to come up with a function where i can get rid of this.
but how do you do it..
well, with php you can.
so we partnered with www.webune.com to come up with a fucntion that cleans up this mess..
so this we came up with this function:
PHP CODE:
function remove($string,$word_limit) {
$words = explode(" ", $string );
for( $i = 0; $i < count($words); ++$i ){
if(strlen($words[$i]) > $word_limit) {
$words[$i] = substr($words[$i], 0, $word_limit );
}
}
$words = implode(" ", $words );
return $words ;
}
now all you have to do is echo the function and provide the values in the function
Exampe:
PHP CODE
$word_limit = 10;
$string = 'sssssssssssssooooooooooooooooooooooooooo coooolllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll';
echo remove($string, $word_limit);
https://www.wallpaperama.com/forums/how-to-remove-long-repeated-letters-in-words-comments-t5754.html