RE: [PHP] Question about "shortening" a string

2005-03-16 Thread Kim Madsen
-Original Message- From: Steve Slater [mailto:[EMAIL PROTECTED] Sent: Saturday, March 12, 2005 5:29 PM $name_array = explode(" ",$name); $short_name = "$name_array[0] " . end($name_array); > And a dozen other ways to do it I'm sure. I just finished a > project with a mess of pattern mat

Re: [PHP] Question about "shortening" a string

2005-03-12 Thread Steve Slater
At 11:54 PM 3/11/2005, Stephen Johnson wrote: Just a quick and dirty solution - but couldn't you explode the name into an array and use the first and last array fields ? $name_array = explode(" ",$name); $short_name = "$name_array[0] " . end($name_array); And a dozen other ways to do it I'm sure.

Re: [PHP] Question about "shortening" a string

2005-03-11 Thread Stephen Johnson
Just a quick and dirty solution - but couldn't you explode the name into an array and use the first and last array fields ? On Mar 11, 2005, at 11:39 PM, Steve Slater wrote: Mario, Many ways to do it, most using regex. This is not as clean as it can be but still shows the idea: This example wor

Re: [PHP] Question about "shortening" a string

2005-03-11 Thread Steve Slater
Mario, Many ways to do it, most using regex. This is not as clean as it can be but still shows the idea: This example works for any number of middle names (including zero) and any number of white spaces between words. You can probably get this more elegant, but this is one idea. Steve In Portgal

[PHP] Question about "shortening" a string

2005-03-11 Thread Mário Gamito
Hi, In Portgal we have big names. My complete name, for instance, is "Mário Augusto Machado dos Reis Gamito". "Mário" is the Christian name and "Gamito" - the last one - is always the last name of the father. I have a form where i want to let my users insert their full big name like mine, but i