http://www.php.web.tr de zamanım oldukça ekliyorum. Siteyi bilmeyenler için kodlar:
Türkçe Destekli strtolower() Fonksiyonu
Türkçe Destekli strtoupper() Fonksiyonu
Türkçe Destekli ucfirst() Fonksiyonu (üstte bulunan tr_strtoupper kullanır)
Türkçe Destekli ucwords() Fonksiyonu (üstte bulunan tr_strtoupper kullanır)
Türkçe Destekli sort() Fonksiyonu
Kolay gelsin.
Türkçe Destekli strtolower() Fonksiyonu
PHP:
<?php
function tr_strtolower($metin) {
$metin = strtr($metin, "IĞÜŞİÖÇ", "ığüşiöç");
return strtolower($metin);
}
# Örnek Kullanımı
echo tr_strtolower("ÖRNEK TÜRKÇE METİN");
?>
PHP:
<?php
function tr_strtoupper($metin) {
$metin = strtr($metin, "ığüşiöç", "IĞÜŞİÖÇ");
return strtoupper($metin);
}
# Örnek Kullanımı
echo tr_strtoupper("örnek türkçe metin");
?>
PHP:
<?php
function tr_ucfirst($metin) {
$metin[0] = tr_strtoupper($metin[0]);
return $metin;
}
# Örnek Kullanımı
echo tr_ucfirst("örnek türkçe metin");
?>
PHP:
<?php
function tr_ucwords($metin) {
$metin[0] = tr_strtoupper($metin[0]);
for ($i = 0; $i < strlen($metin); $i++) {
if (($metin[$i] == " " || $metin[$i] == "(") && isset($metin[$i + 1]))
$metin[$i + 1] = tr_strtoupper($metin[$i + 1]);
}
return $metin;
}
# Örnek Kullanımı
echo tr_ucwords("örnek türkçe metin");
?>
PHP:
<?php
function turkce_sirala($a, $b) {
$turkce = array('ç' => 'c', 'ğ' => 'g', 'ı' => 'i', 'ö' => 'o',
'ş' => 's', 'ü' => 'u', 'Ç' => 'C', 'Ğ' => 'G',
'İ' => 'I', 'Ö' => 'O', 'Ş' => 'S', 'Ü' => 'U');
$a = preg_replace("/(ı|ğ|ü|ş|ö|ç|Ğ|Ü|Ş|İ|Ö|Ç)/e", "\$turkce['\\1'].'~'", $a);
$b = preg_replace("/(ı|ğ|ü|ş|ö|ç|Ğ|Ü|Ş|İ|Ö|Ç)/e", "\$turkce['\\1'].'~'", $b);
if ($a == $b)
return 0;
return ($a < $b) ? -1 : 1;
}
function tr_sort(&$dizi) {
return usort($dizi, "turkce_sirala");
}
# Örnek Kullanımı
$turkce_dizi = array("deneme", "örnek", "ağaç", "php", "ornek");
tr_sort($turkce_dizi);
print_r($turkce_dizi);
?>
Kolay gelsin.