Home > Backend Development > PHP Tutorial > Summary of PHP English letter case conversion function_PHP tutorial

Summary of PHP English letter case conversion function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:30:43
Original
1032 people have browsed it

Convert the first letter of each word to uppercase: ucwords()

Copy code The code is as follows:
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!

$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>

The first letter of the first word is capitalized: ucfirst()

Copy code The code is as follows:
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!

$bar = 'HELLO WORLD!';
$bar = ucfirst($bar);                                    // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>

Change the first letter of the first word to lowercase: lcfirst()

Copy the code The code is as follows:
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld

$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>

Change all letters to uppercase: strtoupper()
Change all letters to lowercase: strtolower()

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764627.htmlTechArticleConvert the first letter of each word to uppercase: ucwords() Copy the code as follows: ?php $foo = ' hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwor...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template