Re: Re: Question about "shortening" a string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux