The Str class also provides three convenient methods for manipulating string capitalization: upper, lower, and title. These are more intelligent versions of the PHP strtoupper, strtolower, and ucwords methods. More intelligent because they can handle UTF-8 input if the multi-byte string PHP extension is installed on your web server. To use them, just pass a string to the method:
echo Str::lower('I am a string.');
echo Str::upper('I am a string.');
echo Str::title('I am a string.');
echo Str::limit($string, 10);
echo Str::words($string, 10);
echo Str::random(32);
echo Str::random(32, 'alpha');
The String class is capable of transforming your strings from singular to plural, and vice versa. First, simply specify the strings you need to convert in the application/config/strings.php file:
'inflection' => array(
'user' => 'users',
'person' => 'people',
'comment' => 'comments',
),
echo Str::plural('user');
echo Str::singular('users');
echo Str::plural('comment', count($comments));
return Str::slug('My First Blog Post!');
return Str::slug('My First Blog Post!', '_');