FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » use of substring in php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: use of substring in php [message #174597 is a reply to message #174592] Tue, 21 June 2011 09:04 Go to previous message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma:
Senior Member
On 6/20/2011 11:19 PM, Co wrote:
> Hi All,
>
> I want to cut down the name of the user to 10 characters so it will
> fit to the picture of the user.
> At this moment I use $firstnameCut = substr($firstname, 0, 10);
> However sometimes the name is like:
>
> Johannes Paul.
> with my code it will show: Johannes P
>
> How can I change this so if the second or third name doesn't fit
> within the 10 characters
> it will not be shown at all?
>
> Regards
> Marco

Hello Marco,

I like using ... to show the visitor that something is cutted away.
eg:
Marco --> Marco
Johannes Paul -> Johannes...

But that works better for longer strings. If you only want 10
characters, the 3 ... take up too much space I expect.

Also, make sure you give your image a title="Johannes Paul" and
alt="Johannes Paul" so everybody can easily find the full name by
hovering over the image.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Compiling PHP error
Next Topic: free computer ebooks updated daily
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 11:51:57 GMT 2024

Total time taken to generate the page: 0.05499 seconds