PHP 8.4.24 Released!

Voting

: six plus one?
(Example: nine)

The Note You're Voting On

qeremy [atta] gmail [dotta] com
14 years ago
A proper Turkish solution;

<?php
function ucfirst_turkish($str) {
    $tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return mb_convert_case(
        str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
        $tmp[1];
}

function ucwords_turkish($str) {
    return preg_replace("/(\\w+)/ue", "ucfirst_turkish('\\\\1').'$2'", $str);
}

$str = "iyilik güzelLİK şeker ";
echo ucwords($str) ."\\n";   // Iyilik GüzelLİK şeker 
echo ucwords_turkish($str); // İyilik GüzelLİK Şeker 
?>

<< Back to user notes page

To Top