lIP TT lIP TT - 1 year ago 69
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

Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download