javascript/php - shorten string to fit into a certain # of lines -


I have a string that should fit in the box, and up to 3 lines should be long. To make it short, I plan to minimize it and end it with '...'. I can shorten it to a certain # character but if I call it "wwwwwww [...] wwww" I would not be right with "iiiiiiiiiii [...] iiii".

Is there any way that I can reduce it by how much space string it will take, in contrast to how many letters are there in the string without using a fixed width font? Ideally I want to do this server-side (PHP), but believe that the actual character width is probably more likely to be client-side (JS / JQ)

rosary

ps. Please create an image of "just" '...' and create "hacks or similar" overlays at the end of the line - I really want to shorten the string in the appropriate length

< Div class = "post-text" itemprop = "text">

There and for it.


Comments