Skip to content

Instantly share code, notes, and snippets.

@ugurerkan
Created April 20, 2012 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugurerkan/2428335 to your computer and use it in GitHub Desktop.
Save ugurerkan/2428335 to your computer and use it in GitHub Desktop.
tr_ucfirst
function tr_ucfirst($str)
{
$f = mb_substr($str, 0,1);
switch($f)
{
case 'i':
$r = 'İ';
break;
case 'ç':
$r = 'Ç';
break;
case 'ü':
$r = 'Ü';
break;
case 'ş':
$r = 'Ş';
break;
case 'ö':
$r = 'Ö';
break;
case 'ı':
$r = 'I';
break;
}
if($r)
{
return preg_replace('#^'.$f.'#',$r,$str);
}
else
{
return ucfirst($str);
}
}
@mavci
Copy link

mavci commented Aug 5, 2018

Bu nasıl;

function tr_ucfirst($string) {
	$from = preg_split('//u', 'abcdefghjklmnopqrstuvwxyzçşöüiı', -1, PREG_SPLIT_NO_EMPTY);
	$to = preg_split('//u', 'ABCDEFGHJKLMNOPQRSTUVWXYZÇŞÖÜİI', -1, PREG_SPLIT_NO_EMPTY);
	return $to[array_search(mb_substr($string, 0, 1), $from)] . mb_substr($string, 1);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment