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."
<?php function initials($name){ $nword = explode(" ",$name); foreach($nword as $letter){ $new_name .= $letter{0}.'.'; } return strtoupper($new_name); } echo initials('John Doe'); ?>
I hope this article will be helpful to everyone’s PHP programming design.