acctman Posted February 8, 2009 Share Posted February 8, 2009 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 More sharing options...
ratcateme Posted February 8, 2009 Share Posted February 8, 2009 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. Link to comment https://forums.phpfreaks.com/topic/144275-solved-help-with-more-to-come/#findComment-757136 Share on other sites More sharing options...
acctman Posted February 8, 2009 Author Share Posted February 8, 2009 thanks, that worked perfectly Link to comment https://forums.phpfreaks.com/topic/144275-solved-help-with-more-to-come/#findComment-757191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.