Backend Development 2 min read

Laravel String Helper Cheat Sheet

This article provides a concise reference of Laravel's String helper functions, describing each method's purpose and showing example code snippets for common string operations such as conversion, case manipulation, searching, and generating random strings.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Laravel String Helper Cheat Sheet

String is a Laravel string helper that offers a collection of static methods for common string manipulation tasks.

String

// 将 UTF-8 的值直译为 ASCII 类型的值
Str::ascii($value)
Str::camel($value)
Str::contains($haystack, $needle)
Str::endsWith($haystack, $needles)
Str::finish($value, $cap)
Str::is($pattern, $value)
Str::length($value)
Str::limit($value, $limit = 100, $end = '...')
Str::lower($value)
Str::words($value, $words = 100, $end = '...')
Str::plural($value, $count = 2)
Str::random($length = 16)
Str::quickRandom($length = 16)
Str::upper($value)
Str::title($value)
Str::singular($value)
Str::slug($title, $separator = '-')
Str::snake($value, $delimiter = '_')
Str::startsWith($haystack, $needles)
Str::studly($value)
Str::macro($name, $macro)
BackendDocumentationPHPString()LaravelHelper
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.