How to implement php string case conversion

藏色散人
Release: 2023-02-28 18:50:02
Original
3023 people have browsed it

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;
?>
Copy after login

Output result:

i want to fly
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!