Jump to content

Split huge words


jaymc

Recommended Posts

Ok, I want to turn this

 

"Helooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"

 

Into something more presentable such as

 

"Helooooooooo"

 

I can do this fine in PHP, i have made the following function;

 

// STOP EXCESIVE SCROLLING
$words = explode(" ", $message);
$wordarray = array();
foreach ($words as $words) {
if(strlen($words)>50){
$words=substr($words, 0, 50);
}
$wordarray[] = $words;
}
$message = join(" ", $wordarray);

 

if you dont know php, ignore that example, if you do then you should know exactly what Im trying to do

 

 

The reason for this is if someone posts a comment and doesnt have a space in a stupid word 50 chars long, it stretches the table or div its in

 

The way around it is to identify words that are over 50 chars and cut them off at char 50, as per my example above

 

How can this be acheived in javascript?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.