Home  >  Article  >  Backend Development  >  How to implement php string case conversion

How to implement php string case conversion

藏色散人
藏色散人Original
2020-04-24 16:01:002994browse

How to implement php string case conversion

How to implement string case conversion in php

php case conversion function

1. Convert the string to lowercase

strtolower(): This function converts all characters of the passed string parameter into lowercase and puts the character back in small definite form String.

Example:

<?php
    $str = "I want To FLY";
    $str = strtolower($str);
    echo $str;
?>

Output result:

i want to fly

2. Convert characters to uppercase

strtoupper(): The function of this function is opposite to the strtolower function. It converts all the characters of the incoming character parameters into uppercase letters and returns the string in uppercase letters. The usage is the same as strtolowe().

3. Convert the first character of the string to uppercase

usfilst(): The function of this function is to change the first character of the string to uppercase. This function returns the string with the first character uppercase.

Usage is the same as strtolowe().

4. Convert the first character of each word in the string to uppercase

ucwords(): This function converts the incoming characters The first character of each word in the string becomes uppercase. For example, "hello world", after being processed by this function

, will return "Hello Word". The usage is the same as strtolowe().

For more related knowledge, please pay attention to

PHP中文网

! !

The above is the detailed content of How to implement php string case conversion. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn