Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-13 09:46:36
Original
1123 people have browsed it

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;>

Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template