Published
6: New Multibyte String Functions: mb_trim, mb_ucfirst, and mb_lcfirst
Handling string manipulation on multibyte text (such as non-ASCII or internationalized content) used to require manual workarounds because core functions like trim() or ucfirst() only worked reliably on single-byte strings. PHP 8.4 bridges this gap by adding dedicated multibyte helper functions: mb_trim(), mb_ltrim(), mb_rtrim(), mb_ucfirst(), and mb_lcfirst().
PHP 8.4 Example:
PHP
$text = " hello world ";
$trimmed = mb_trim($text);
$str = "unicode";
$capitalized = mb_ucfirst($str);
echo $trimmed; // Outputs: hello world
echo $capitalized; // Outputs: UnicodeThe articles and images featured on this platform were generated with the assistance of AI tools.