- preg_replace_callback: documentation ( source)
- ucfirst: documentation ( source)
<?php
$str = "luke";
echo preg_replace_callback('~^(?![eiux])[a-z]~', function($m) {
return ucfirst($m[0]);
}, $str);
$str = "egg";
echo "\n" . preg_replace_callback('~^(?![eiux])[a-z]~', function($m) {
return ucfirst($m[0]);
}, $str);