lIP TT lIP TT - 2 months ago 6x
PHP Question

PHP finish text with ... if it is too long

I have got div with width of 300 and i have also got children span in it text of which doesn't depend on me.If span's text is


It should stop after five

,but if text is

It should stop after 10


There's no need to apply any PHP programming logic here.

This thing can be achieved in CSS easily.

.text-ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;

And add this class to your span:

<span class="text-ellipsis">WWWWWWWWWWWWW</span>