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 #174594 is a reply to message #174592] Tue, 21 June 2011 00:40 Go to previous messageGo to previous message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma:
Senior Member
On 6/20/2011 5: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?

This is not a PHP answer per se. Give some though to using the first X
characters from the first name and the first Y characters from the last
name. It may resolve some of your dilemma. It has a favorable side
effect of producing a decently unique set of characters (most of the time).

Bill B
[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: Sat Nov 23 08:53:24 GMT 2024

Total time taken to generate the page: 0.03267 seconds