Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Date: Tue, 22 May 2012 20:30:45 +0200 From: Luuk User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.php Subject: Re: PHP Concatenate References: <9ee80c71-db8e-4adf-8f59-03d2749fbe5b@googlegroups.com> <4FBA9549.7090409@invalid.lan> <858nr71tltm4060g71pad72js50kj4ugs5@news.eternal-september.org> In-Reply-To: <858nr71tltm4060g71pad72js50kj4ugs5@news.eternal-september.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: Lines: 66 NNTP-Posting-Host: 2001:980:9089:1:4c18:7c29:b17b:63d5 X-Trace: 1337712001 news.xs4all.nl 6952 [2001:980:9089:1:4c18:7c29:b17b:63d5]:59239 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.php:6123 On 22-05-2012 16:21, Paul Herber wrote: > On Tue, 22 May 2012 08:42:54 -0500, "Peter H. Coffin" 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. > > > output: Kevin De'Ath J. Tolkien