Re: Re: Question about "shortening" a string

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

 



Mário Gamito wrote:

Hi Sokolewicz,

Thanks a lot.
It just working really fine :)

M. Sokolewicz wrote:

> Mário Gamito wrote:
>
>> For example, if i fill the form with "Mário Augusto Machado dos Reis Gamito", i want to change this string to only "Mário Gamito".
>>
>> The total number of names is not fix.
>> Could be 3, 4, 5, 6,...
>>
>> 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.

--
H | I haven't lost my mind; it's backed up on tape somewhere.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:ashley@xxxxxxxxxx> . 303.442.6410 x130
IT Director / SysAdmin / WebSmith . 800.441.3873 x130
Photo Craft Imaging . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.


--
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