This is what I was trying to achieve:
function name_case($string)
{
$values = explode(" ", $string);
$values = array_filter(array_map('trim', $values));
foreach($values as $key => $value)
{
if(strlen($value) > 3 && ctype_alpha($value))
{
$values[$key] = ucwords(strtolower($value));
}
else $values[$key] = strtoupper($value);
}
return implode(" ", $values);
}
This:
print_r(name_case("akg VMS 2321k raDio MiCroPhone "));
Gives us:
AKG VMS 2321K Radio Microphone
and this:
print_r(name_case(" shure sm 58 radio microphone & shure vms-221 receiver "));
gives us:
Shure SM 58 Radio Microphone & Shure VMS-221 Receiver
Makes for a more visually pleasing product title.