LoginSignup
5
4

More than 5 years have passed since last update.

[PHP] 文字列の1文字目を大文字にする

Last updated at Posted at 2014-05-22

追記

タイトルの処理がしたい時は、ucfirst関数を使いましょう!
http://www.php.net/manual/ja/function.ucfirst.php

しかも下の処理だと、参照されていないので
変更はされないし、新しい格納領域をつくったりしてしまうので
ちゃんと参照しましょう。
http://jp2.php.net/manual/ja/language.references.pass.php
mpywさん、ありがとうございました!


配列に文字列がおさまっていて、
1文字目に何らかの処理をしたい時。

first_char.php
foreach ($ary as $val) {
    $val[0] = strtoupper($val[0]);
    ....
    }

配列から取り出した文字列の1文字目を参照するって、
すっごく無理があるというか、独特な感じがいたしました。
なんかとても気持ち悪い……

5
4
10

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
5
4