MySQL Forums
Forum List  »  Newbie

Re: How can I convert a string containing a few names into its initials?
Posted by: Sarabjit Singh
Date: August 20, 2005 08:55AM

1. tokenize the string
2. cut each token
3. join them back together

<?php

..
..

$fullName='James Henry William';
$initials='';
$nameParts=explode(' ',$fullName);
foreach($nameParts as $v) {
$initials.=substr($v,0,1).'.';
}
# $initials will now have the intials - J.H.W.

..
..

?>

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.