Home > Article > Backend Development > 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!