Re: Re: Question about "shortening" a string

From: Date: Sat, 12 Mar 2005 22:04:06 +0000
Subject: Re: Re: Question about "shortening" a string
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-210599@lists.php.net to get a copy of this message
Ashley M. Kirchner wrote:
Mário Gamito wrote:
...
Does anyone knows how to do this ?
<?php $parts = explode(' ', $fullName); $shortenedName = $parts[0].' '.$parts[count($parts)-1]; ?>
This might solve one problem. What about people who have names like 'Pablo Ricardo del Rey' where you can't simply pick first and last because their last name really is 'del Rey'. Or 'von Braun', or ...you get the idea.
I thought so too... I thought maybe you could just provide 3 name text boxes: <input name="firstname" /><input name="middlenames" /><input name="lastname" /> and store the names seperately, then you could display the short or long version at will... additionally using substr() and the explode() technique described above you can also generate their initials to create an even shorter version of the name.

« previous php.general (#210599) next »