- explode: documentation ( source)
- strtoupper: documentation ( source)
- in_array: documentation ( source)
<?php
function initials($str)
{
$ret = '';
$proibidos = ['de', 'da','das','do'];
$word = explode(' ', $str);
foreach ($word as $w)
{
if(!in_array($w,$proibidos)){
$ret .= strtoupper($w[0]);
}
}
return $ret;
}
echo initials('igor carvalho de paula');