Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6109 > unrolled thread
| Started by | Kevin Davis <kevindavis338@gmail.com> |
|---|---|
| First post | 2012-05-21 11:47 -0700 |
| Last post | 2012-06-04 23:33 -0700 |
| Articles | 11 — 9 participants |
Back to article view | Back to comp.lang.php
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
| From | Kevin Davis <kevindavis338@gmail.com> |
|---|---|
| Date | 2012-05-21 11:47 -0700 |
| Subject | PHP Concatenate |
| Message-ID | <9ee80c71-db8e-4adf-8f59-03d2749fbe5b@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | bill <nobody@spamcop.net> |
|---|---|
| Date | 2012-05-21 15:17 -0400 |
| Message-ID | <18OdnWc3FbsrCSfSnZ2dnUVZ_gudnZ2d@cablespeedmi.com> |
| In reply to | #6109 |
On 5/21/2012 2:47 PM, 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 I really hate to ask these because I fear the answers: will there always be a middle initial ? Will there be any first or last names with embedded spaces ? (eg Jean Paul Aloysius Smith ? bill
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-05-21 21:19 +0200 |
| Message-ID | <4FBA9549.7090409@invalid.lan> |
| In reply to | #6109 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-05-22 08:21 -0400 |
| Message-ID | <jpg0cd$mh3$1@dont-email.me> |
| In reply to | #6113 |
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"?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2012-05-22 08:42 -0500 |
| Message-ID | <slrnjrn5uu.4ci.hellsop@nibelheim.ninehells.com> |
| In reply to | #6115 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Paul Herber <paul@pherber.com> |
|---|---|
| Date | 2012-05-22 15:21 +0100 |
| Message-ID | <858nr71tltm4060g71pad72js50kj4ugs5@news.eternal-september.org> |
| In reply to | #6116 |
On Tue, 22 May 2012 08:42:54 -0500, "Peter H. Coffin" <hellsop@ninehells.com> wrote:
>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.
and anyone with the surname De'Ath.
--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-05-22 16:37 +0100 |
| Message-ID | <jpgbse$gl7$3@news.albasani.net> |
| In reply to | #6117 |
Paul Herber wrote:
> On Tue, 22 May 2012 08:42:54 -0500, "Peter H. Coffin" <hellsop@ninehells.com> wrote:
>
>> 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.
>
> and anyone with the surname De'Ath.
>
>
He assisted with my late mothers will, did Mr De'Ath. Genuinely!
>
--
To people who know nothing, anything is possible.
To people who know too much, it is a sad fact
that they know how little is really possible -
and how hard it is to achieve it.
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-05-22 20:18 +0200 |
| Message-ID | <0t1t89-5ou.ln1@luuk.invalid.lan> |
| In reply to | #6117 |
On 22-05-2012 16:21, Paul Herber wrote:
> On Tue, 22 May 2012 08:42:54 -0500, "Peter H. Coffin" <hellsop@ninehells.com> wrote:
>
>> 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.
>
> and anyone with the surname De'Ath.
>
>
>
~/tmp> cat surname.php
<?php
$name="Kevin R. De'Ath";
$a=split(" ",$name);
print $a[0]." ".$a[count($a)-1];
?>
~/tmp> php surname.php
Kevin De'Ath
~/tmp>
But, of course, this method is not perfect and/or complete.
But where is the OP.....?
Why does not he/she give a clue about what is expected?
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-05-22 20:30 +0200 |
| Message-ID | <kj2t89-squ.ln1@luuk.invalid.lan> |
| In reply to | #6117 |
On 22-05-2012 16:21, Paul Herber wrote:
> On Tue, 22 May 2012 08:42:54 -0500, "Peter H. Coffin" <hellsop@ninehells.com> wrote:
>
>> 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.
>
> and anyone with the surname De'Ath.
>
>
>
<?php
$name="Kevin R. De'Ath";
$a=split(" ",$name);
print $a[0]." ".$a[count($a)-1];
print "\n";
// Second solution, so J. R. R. Tolkien is also handled correctly
$name="J. R. R. Tolkien";
$a=split(" ",$name);
for ($f=0; $f<count($a); $f++)
if (substr($a[$f],strlen($a[$f])-1,1)!="." or $f==0) print
$a[$f]." ";
print "\n";
?>
output:
Kevin De'Ath
J. Tolkien
[toc] | [prev] | [next] | [standalone]
| From | Captain Paralytic <paul_lautman@yahoo.com> |
|---|---|
| Date | 2012-05-22 04:34 -0700 |
| Message-ID | <a602016e-3119-4feb-b9fc-4655cbc650a8@w10g2000vbc.googlegroups.com> |
| In reply to | #6109 |
On May 21, 7:47 pm, Kevin Davis <kevindavis...@gmail.com> 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?? You might if you wanted and if the full problem had a decent regex solution to match it. However as Bill and Luuk have shown, you have not given enough data in order for us to evaluate it.
[toc] | [prev] | [next] | [standalone]
| From | Nick Brooks <nbrooks@thirtyseven.com.au> |
|---|---|
| Date | 2012-06-04 23:33 -0700 |
| Message-ID | <ba529af7-af43-4a49-9db0-8dacf0ded4bb@googlegroups.com> |
| In reply to | #6109 |
Cool stuff guys!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web