Jump to content

How can I limit "word length"?


floridaflatlander
 Share

Recommended Posts

I have a div 120px in width that contains a thumb nail and a title under it.

My problem is if a word in the title is over X (20+ I think) characters the div gets wider to hold all the characters in a word.

 

I can limit the string length with substr, but I want to limit the length of a word in a string.

 

How do I limit a words length?

 

Thanks

S

Link to comment
Share on other sites

How would I use substr() to limit word length?

 

I can use it to limit a string like $title = substr ($title, 0, 100);

 

But I want to limit the size of a word in the string.

 

So if I have var thats $title = " A Cow Jumped Over The Mooooooooooooooooooooooooooooooooon" how can I change it to " A Cow Jumped Over The Mooooooooooo oooooooooooo oooooooooon" for the reason listed above.

 

 

Thanks for the reply

Link to comment
Share on other sites

Thanks All

 

The {word-wrap: break-word;} worked like a charm however I check with w3.org and it said "Property word-wrap doesn't exist :"  But I'm still going to use it, I played with it in ie7, 8 & firefox and it worked great.

 

I looked at php.net and wordwrap() may not do what I want because even though the index page will have thumbnails the picture page would need the full unbroken title or there abouts because the picture would have more room on it's own page.

 

Thanks again I'm going to work with them both more as I get more time tonight and tomorrow.

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.