Solved

How to shorten a to long name?

Posted on 1998-11-21
7
162 Views
Last Modified: 2010-03-04
It should do the following:
e.g.


old name >> thisnameistolong

names longer than 10 should be converted in >> thisnameis..


if(length($name) > 10) {

$name = ?;

}


Regards,

Bigi
0
Comment
Question by:Bigi
  • 4
  • 2
7 Comments
 
LVL 4

Expert Comment

by:martinag
ID: 1206427
$name = substr($name,0,10) if length($name) > 10;

Martin
0
 
LVL 4

Expert Comment

by:martinag
ID: 1206428
I didn't see the two spots. Add using ."..":
$name = substr($name,0,10).".." if length($name) > 10;

Martin
0
 

Author Comment

by:Bigi
ID: 1206429
Thanks!

How can I grade it?

Please reply with "answer" (not comment) so I can send
you the points.

Regards,

Bigi
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Accepted Solution

by:
martinag earned 80 total points
ID: 1206430
$name = substr($name,0,10).".." if length($name) > 10;

Martin
0
 

Author Comment

by:Bigi
ID: 1206431
Adjusted points to 80
0
 
LVL 4

Expert Comment

by:martinag
ID: 1206432
Thanks.

Martin
0
 
LVL 84

Expert Comment

by:ozo
ID: 1206433
#or
substr($name,10)='..'
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now