- array_map: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
- array_filter: documentation ( source)
<?php
function first_letter($str)
{
return implode('', array_map(function($v) { return $v[0]; },array_filter(array_map('trim',explode(' ', $str)))));;
}
$str=" Let's try with more spaces for fun . ";
echo first_letter($str);
?>