Skip to content
Justice Tech School

More String Functions

trim, ltrim, rtrim, ucwords, wordwrap, nl2br, str_pad, str_repeat, strrev, similar_text, levenshtein, number_format and mb_ functions for Unicode.

Example
echo ucwords("hello php world"), "\n";
echo str_pad("7", 3, "0", STR_PAD_LEFT), "\n";
echo strrev("abc"), " ", str_repeat("ab", 3), "\n";
echo number_format(1234567.891, 2), "\n";
echo strlen("héllo"), " ", mb_strlen("héllo"), "\n";
echo ucfirst(strtolower("ADA")), "\n";

Result

Hello Php World
007
cba ababab
1,234,567.89
6 5
Ada

Exercise

Count Unicode characters.

("héllo")

Quiz Test

Which counts characters, not bytes?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.