LoginSignup
6
1

More than 5 years have passed since last update.

PHPで大文字・小文字の変換をしたい

Last updated at Posted at 2018-04-10

PHPで大文字

echo strtoupper("Horikwa\n");
echo strtoupper("hiyoko\n");
echo strtoupper("TOKIYA\n");
echo strtoupper("PHPer\n");

結果

HORIKAWA
HIYOKO
TOKIYA
PHPER

PHPで小文字

echo strtolower("Horikwa\n");
echo strtolower("hiyoko\n");
echo strtolower("TOKIYA\n");
echo strtolower("PHPer\n");

結果

horikawa
hiyoko
tokiya
phper

PHPで頭文字だけ大文字

echo ucwords(strtolower("HORIKAWA Tokiya"));

結果

Horikawa Tokiya

上記はstrtolowerで全て小文字に変換された後にucwordsで頭文字だけ大文字に変換しています。

ググったら一瞬で出る記事ですがアウトプットの習慣付けのために書きました。

6
1
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
6
1