LoginSignup
10
11

More than 5 years have passed since last update.

Laravelのstr_plural/str_singularが何気に凄い

Posted at

Laravelのヘルパーであるstr_plural(単語を複数形に変換)とstr_singular(単語を単数形に変換)ですが、
かなり凄いです。

bookとかは、まー当然ですよね。

echo str_plural('book');
>books
echo str_singular('books');
>book

では、historyは?

echo str_plural('history');
>histories
echo str_singular('histories');
>history

ここまでは想定の範囲内。

では、childは?

echo str_plural('child');
>children
echo str_singular('children');
>child

おぉ!ではmanは?

echo str_plural('man');
>men
echo str_singular('men');
>man

続いて、mouse

echo str_plural('mouse');
>mice
echo str_singular('mice');
>mouse

これでどうだ!phenomenon

echo str_plural('phenomenon');
>phenomena
echo str_singular('phenomena');
>phenomenon

素晴らしい!!

...が、しかし

echo str_plural('carp');
>carps
echo str_singular('carps');
>carp

むぅ・・・まぁこれは仕方ないですかね。

10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11