웹개발/PHP
[PHP] strtolower / strtoupper / ucfirst / ucwords - 문자열 대/소문자로
우주별
2017. 10. 20. 10:27
▤ strtolower(string) : 소문자로
<?php
$str = strtolower("HELLO WORLD");
echo $str; //hello world
?>
▤ strtoupper(string) : 대문자로
<?php
$str = strtoupper("hello world");
echo $str; //HELLO WORLD
?>
▤ ucfirst(string) : 첫 글자만 대문자로. 나머지는 그대로.
<?php
$str1 = ucfirst("hello world");
echo $str1; //Hello world
$str2 = ucfirst("hElLo wORld");
echo $str2; //HElLo wORld
?>
▤ ucwords(stirng) : 각 단어의 첫 글자만 대문자로. 나머지는 그대로.
<?php
$str1 = ucwords("hello world");
echo $str1; //Hello World
$str2 = ucwords("hElLo wORld");
echo $str2; //HElLo WORld
?>