Jump to content

[SOLVED] Help with more to come "..."


acctman

Recommended Posts

I'm displaying user names and some are two long to fit perfectly on my main screen, how can I add ... when the name is too long when display.

 

11 characters can fit perfectly, so if the user name is more than 11 then cut it off at the 8th character an add ...

 

ex.

Qwertyuiopa

A1234567... (actual name A1234567USER)

Link to comment
https://forums.phpfreaks.com/topic/144275-solved-help-with-more-to-come/
Share on other sites

echo strlen($username) > 11? substr($username,0,."...": $username;

and it can be used inline like

echo "<div>" . (strlen($username) > 11? substr($username,0,."...": $username) . "</div>";

the brackets are not needed but make it easier to read

 

Scott.

Archived

This topic is now archived and is closed to further replies.

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