By John Koster
The singular
helper method is the logical opposite to the plural
method: it will attempt to take a given $value
and return the singular form of that word. The internal mechanisms are similar to the plural
method.
The signature for the singular
helper method is:
singular($value)
1use Illuminate\Support\Str;
2
3// cow
4echo Str::singular('cows');
5
6// person
7echo Str::singular('people');
8
9// curve
10echo Str::singular('curves');
11
12// message
13echo Str::singular('messages');
#str_singular($title)
The str_singular
function is a shortcut to calling Str::singular
. This function is declared in the global namespace.
∎