라이브러리

[PHP] mb_convert_case - 문자열에 대한 대소문자 구분 수행




PHP의 `mb_convert_case` 함수는 문자열을 대문자 또는 소문자로 변환하는 데 사용됩니다. 이 함수는 `mb_strtoupper`와 `mb_strtolower` 함수를 결합하여 사용할 수 있습니다.

mb_convert_case 함수의 사용법


`mb_convert_case` 함수는 두 개의 매개변수를 받습니다.

- 첫 번째 매개변수는 변환할 문자열입니다.
- 두 번째 매개변수는 변환 타입입니다. 이 매개변수는 다음과 같은 값을 가질 수 있습니다.

- `MB_CASE_UPPER` : 대문자로 변환
- `MB_CASE_LOWER` : 소문자로 변환
- `MB_CASE_TITLE` : 단어의 첫 글자를 대문자로, 나머지 글자를 소문자로 변환

예제


#hostingforum.kr
php

// 대문자로 변환

$str = "hello world";

echo mb_convert_case($str, MB_CASE_UPPER) . "
"; // HELLO WORLD



// 소문자로 변환

$str = "HELLO WORLD";

echo mb_convert_case($str, MB_CASE_LOWER) . "
"; // hello world



// 단어의 첫 글자를 대문자로, 나머지 글자를 소문자로 변환

$str = "hello world";

echo mb_convert_case($str, MB_CASE_TITLE) . "
"; // Hello World



참고


- `mb_convert_case` 함수는 `mb_strtoupper`와 `mb_strtolower` 함수를 결합하여 사용할 수 있습니다. 예를 들어, `mb_convert_case` 함수를 대문자로 변환하는 데 사용할 수 있습니다.

#hostingforum.kr
php

$str = "hello world";

echo mb_strtoupper($str) . "
"; // HELLO WORLD



- `mb_convert_case` 함수는 `mb_strtolower` 함수와 마찬가지로 문자열의 인코딩을 인식할 수 있어야 합니다. 예를 들어, `UTF-8` 인코딩을 사용하는 경우 `mb_convert_case` 함수를 사용할 수 있습니다.

#hostingforum.kr
php

$str = "hello world";

echo mb_strtolower($str, 'UTF-8') . "
"; // hello world



- `mb_convert_case` 함수는 `mb_strtoupper`와 `mb_strtolower` 함수를 결합하여 사용할 수 있습니다. 예를 들어, `mb_convert_case` 함수를 대문자로 변환하는 데 사용할 수 있습니다.

#hostingforum.kr
php

$str = "hello world";

echo mb_strtoupper($str, 'UTF-8') . "
"; // HELLO WORLD


  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 423 페이지

검색

게시물 검색