- preg_replace_callback: documentation ( source)
<?php
function remove_shout($_text,$_max_caps=3)
{
return preg_replace_callback('/[A-Z]{$_max_caps,}/',create_function('$matches','return strtolower($matches[0]);'),$_text);
}
$input = "This is so AWESOME COOL!";
echo remove_shout($input);