How to shorten a to long name?

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
BigiAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
martinagConnect With a Mentor Commented:
$name = substr($name,0,10).".." if length($name) > 10;

Martin
0
 
martinagCommented:
$name = substr($name,0,10) if length($name) > 10;

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

Martin
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
BigiAuthor Commented:
Thanks!

How can I grade it?

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

Regards,

Bigi
0
 
BigiAuthor Commented:
Adjusted points to 80
0
 
martinagCommented:
Thanks.

Martin
0
 
ozoCommented:
#or
substr($name,10)='..'
0
All Courses

From novice to tech pro — start learning today.