PHP ucwords() Function with Example

PHP ucwords() Function with Example

PHP ucwords() Function: Here, we will find out about the ucwords() work with the example in PHP.

PHP ucwords() Function

ucwords() work is a string capacity in PHP and it is utilized to changes over the primary characters in capitalized of all words in a string.

Syntax:

    ucwords(string);

Example:

    Input: "hello world how are you?"
    Output: "Hello World How Are You?"

    Input: "hello123"
    Output: "Hello123"

PHP Code:

<?php
	$str = "hello world how are you?";
	echo (ucwords($str) . "\n");

	$str = "HELLO world how are you?";
	echo (ucwords($str) . "\n");	

	$str = "hello123 123hello";
	echo (ucwords($str) . "\n");		
?>

Output:

Hello World How Are You?
HELLO World How Are You?
Hello123 123hello

Recent Posts

error: Alert: Content is protected!!