Home  >  Article  >  Backend Development  >  How to get the initials of an English name in php, _PHP tutorial

How to get the initials of an English name in php, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:46:361057browse

How to get the initials of English names in php,

The example in this article describes the method of getting the initials of English names in php. Share it with everyone for your reference. The details are as follows:

This code can analyze and output the first letters of the name based on the English name entered by the user, such as "Billy Bob" to "B.B."

<&#63;php 
function initials($name){ 
  $nword = explode(" ",$name); 
  foreach($nword as $letter){ 
    $new_name .= $letter{0}.'.'; 
  } 
  return strtoupper($new_name); 
} 
echo initials('John Doe'); 
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1031481.htmlTechArticleHow to get the initials of English names in php. This article describes the method of getting the initials of English names in php. Share it with everyone for your reference. The details are as follows: This code can be used according to...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn