Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6116

Re: PHP Concatenate

From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: PHP Concatenate
Date 2012-05-22 08:42 -0500
Organization A noiseless patient Spider
Message-ID <slrnjrn5uu.4ci.hellsop@nibelheim.ninehells.com> (permalink)
References <9ee80c71-db8e-4adf-8f59-03d2749fbe5b@googlegroups.com> <4FBA9549.7090409@invalid.lan> <jpg0cd$mh3$1@dont-email.me>

Show all headers | View raw


On Tue, 22 May 2012 08:21:27 -0400, Jerry Stuckle wrote:
> On 5/21/2012 3:19 PM, Luuk wrote:
>> On 21-05-2012 20:47, Kevin Davis wrote:
>>> Hi there,
>>>
>>> Here is what I'm trying to do.. I'm trying to merge the first and
>>> last name (that I can do) into an email address. But what I'm
>>> trying to do is to drop the middle initial. If the entry was from a
>>> form, I would have no problem, but the data will be uploaded from a
>>> different source, how would I go about dropping the middle initial?
>>>
>>> Would I use regex??
>>>
>>> Thank you,
>>> Kevin
>>
>> $name="Kevin R. Davis";
>> $a=split(" ",$name);
>> print $a[0]." ".$a[count($a)-1];
>>
>> It should print:
>> Kevin Davis
>
> What about "John Smith Jr"?

Or "Carlos Salinas de Gortari"?

To cut to the important point, "dropping middle initial" is a kind
of simple problem surround by worm-cans with very weak lids. Pretty
much the least damaging thing you can do is drop punctuation and any
single-letter (not single character, just Latin letter) words, using two
passes with regexp processing. Usually if someone has put something into
a field on form asking for their name, whatever they've put there is
important to them.

You'll still piss off will.i.am of The Black-Eyed Peas even with that
simple step.

-- 
Never correct Halloween decorations where the guidance counselor can see.
It makes for very tedious conversations later.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

PHP Concatenate Kevin Davis <kevindavis338@gmail.com> - 2012-05-21 11:47 -0700
  Re: PHP Concatenate bill <nobody@spamcop.net> - 2012-05-21 15:17 -0400
  Re: PHP Concatenate Luuk <luuk@invalid.lan> - 2012-05-21 21:19 +0200
    Re: PHP Concatenate Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-22 08:21 -0400
      Re: PHP Concatenate "Peter H. Coffin" <hellsop@ninehells.com> - 2012-05-22 08:42 -0500
        Re: PHP Concatenate Paul Herber <paul@pherber.com> - 2012-05-22 15:21 +0100
          Re: PHP Concatenate The Natural Philosopher <tnp@invalid.invalid> - 2012-05-22 16:37 +0100
          Re: PHP Concatenate Luuk <luuk@invalid.lan> - 2012-05-22 20:18 +0200
          Re: PHP Concatenate Luuk <luuk@invalid.lan> - 2012-05-22 20:30 +0200
  Re: PHP Concatenate Captain Paralytic <paul_lautman@yahoo.com> - 2012-05-22 04:34 -0700
  Re: PHP Concatenate Nick Brooks <nbrooks@thirtyseven.com.au> - 2012-06-04 23:33 -0700

csiph-web