Continue to destroy all characters in the string

醉折花枝作酒筹
Release: 2023-03-11 21:34:01
Original
1710 people have browsed it

In the previous article, we learned about how to change the case of the first character of a string. If you need it, please read "The first character of a string is a disaster!" 》. This time we will introduce to you how to change the case of string characters. You can refer to it if you need it.

We left two functions unmentioned before. I don’t know if you are still impressed. If it doesn’t affect you, read my last article again. This time we will introduce these two functions.

First of all, we introduce the function that converts all characters to uppercase.

Let’s look at a small example.

<?php
echo strtoupper("Hello WORLD!");
?>
Copy after login

The result is

Continue to destroy all characters in the string

We will know the meaning of this function by looking at the result. The strtoupper function can convert all characters in the string Convert to uppercase, so that when we view the output results, all characters will be uppercase.

After we know this function, let's take a look at its usage, give yourself a deeper influence, and remember this function.

strtoupper(要转换的字符串)
Copy after login
Copy after login

Now that we’ve finished talking about the function that converts all characters to uppercase, let’s talk about the function that converts all characters to lowercase.

Let’s take a look at a little chestnut.

<?php
echo strtolower("Hello WORLD.");
?>
Copy after login

This result is

Continue to destroy all characters in the string

The function of this function is opposite to the strtoupper function. It converts all the characters of the incoming character parameters into lowercase and ends with Returns this string in lowercase form. The usage is the same as strtoupper().

Although it's the same, let's take a look at the usage of this function to deepen our impression.

strtoupper(要转换的字符串)
Copy after login
Copy after login

Finally, let’s recommend a few commonly used functions.

When writing PHP programs, you often need to convert uppercase and lowercase strings, which are very useful. (ps: including those introduced before)

strtolower() //Convert the string to lowercase form

strtoupper() //Convert the string to uppercase form

lcfirst() //Convert the first character of the string to lowercase form

ucfirst() //Convert the first character of the string to uppercase

ucwords() //Convert the first letter of each word in the string That’s it for the capitalized form

. If you want to know anything else, you can click this. → →php video tutorial

The above is the detailed content of Continue to destroy all characters in the string. 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