Home > Backend Development > PHP Tutorial > PHP converts the first character of each word in a string to uppercase using the function ucwords()

PHP converts the first character of each word in a string to uppercase using the function ucwords()

黄舟
Release: 2023-03-17 07:20:01
Original
1481 people have browsed it

Example

Convert the first character of each word to uppercase:

<?php
echo ucwords("hello world");
?>
Copy after login
Copy after login

Definition and usage

ucwords() function converts the string Convert the first character of each word in to uppercase.

Note: This function is binary safe.

Related functions:

Syntax

ucwords(string)
Copy after login

ParametersDescriptionstringRequired. Specifies the string to be converted.
Technical details

Return value: Returns the converted stringPHP version: 4+
ucwords example

Put the first character of each word Convert to uppercase:

<?php
echo ucwords("hello world");
?>
Copy after login
Copy after login


The above is the detailed content of PHP converts the first character of each word in a string to uppercase using the function ucwords(). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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