Introduction to the usage of PHP case conversion functions (strtolower, strtoupper)

WBOY
Release: 2016-07-25 08:58:24
Original
1403 people have browsed it
This article introduces the usage of the case conversion functions strtolower and strtoupper in PHP, which are often encountered in character processing problems. Friends in need, please refer to it.

1, Convert string to lowercase strtolower function: This function converts all characters of the incoming string parameter to lowercase and puts them back into the string in decimal form. Example:

<?php
    $str = "I want To FLY";
    $str = strtolower($str);
    echo $str;
//by bbs.it-home.org
?>
Copy after login

Output: i want to fly

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

Here are two more useful functions.

3. Convert the first character of the string to uppercase ucfirst function: 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. The usage is similar to the strtolower() function.

4, convert the first character of each word in the string to uppercase ucwords: This function capitalizes the first character of each word in the passed string. For example, "hello world", after processing by this function, "Hello Word" will be returned. Usage is similar to strtolower().



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!