ShoeLace1291 Posted April 28, 2008 Share Posted April 28, 2008 I have a database query that pulls a member's name out of the table. How would add "..." to the end of the name if the string is more than 7 characters? For example, the members would be John Smith, John Doe, Jane Doe. How would I make it appear like this: Jane Do... John Sm... John Do... Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 I don't know how to do this in MySQL but here is how you could do it in PHP <?php $name = 'Jane Doe'; if (strlen($name) > 7) { $name = substr($name, 0, 7) . '...'; } ?> http://us3.php.net/substr http://us3.php.net/manual/en/function.strlen.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.