Home  >  Article  >  Backend Development  >  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()

黄舟
黄舟Original
2017-11-07 09:03:461431browse

Example

Convert the first character of each word to uppercase:

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

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)

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");
?>


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!

Statement:
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