php文字列の頭文字変換大文字と小文字のインスタンス共有
3191 ワード
phpで文字列の頭文字を大文字と小文字に変換する例.in:バックエンドプログラムの頭文字が大文字になる:ucwords()
最初の単語の頭文字が大文字になります:ucfirst()
最初の単語の頭文字の小文字lcfirst()
アルファベット大文字:strtoupper()
アルファベット小文字:strtolower()
<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
最初の単語の頭文字が大文字になります:ucfirst()
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
最初の単語の頭文字の小文字lcfirst()
<?php
//by www.jbxue.com
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
アルファベット大文字:strtoupper()
アルファベット小文字:strtolower()