PHP 8.5.0 Alpha 1 available for testing

Voting

: two plus one?
(Example: nine)

The Note You're Voting On

mingalevme at gmail dot com
11 years ago
Implementation of multi-bytes ucfirst for "multiword"-strings (module mbstring is required):

<?php

public static function ucfirst($str)
{
$str = mb_strtolower($str);
$words = preg_split('/\b/u', $str, -1, PREG_SPLIT_NO_EMPTY);
foreach (
$words as $word) {
$ucword = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1);
$str = str_replace($word, $ucword, $str);
}
return
$str;
}

?>

<< Back to user notes page

To Top