PHP 8.4.24 Released!

Voting

: seven minus four?
(Example: nine)

The Note You're Voting On

Ukio
10 years ago
Maybe it help someone.
Make up case with first char, low case for other.

<?php
function str_split_unicode($str, $l = 0) {
    if ($l > 0) {
        $ret = array();
        $len = mb_strlen($str, "UTF-8");
        for ($i = 0; $i < $len; $i += $l) {
            $ret[] = mb_substr($str, $i, $l, "UTF-8");
        }
        return $ret;
    }
    return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
}

function ToCorrectCase($str){

    $str = mb_strtolower($str);
    $str_array = str_split_unicode($str);
    $str_array[0] = mb_strtoupper($str_array[0]);
    $str = '';
    foreach ($str_array as $key){
        $str = $str.$key;
    }
    return $str;
}
?>

<< Back to user notes page

To Top