DEV Community

Discussion on: Daily Challenge #38 - Middle Name

Collapse
 
mangelsnc profile image
Miguel Ángel Sánchez Chordi

PHP Solution

<?php

 $fullName = $argv[1];
 $components = explode(' ', $fullName);
 for ($i=1; $i<= count($components) - 2; $i++) {
     $components[$i] = strtoupper($components[$i][0]) . '.';
 }

 echo implode (' ', $components);