Friday, April 6, 2012

Uppercase the first character of each word in a string using PHP.

We can capitalize the first character of each word using a simple php function. Use the below PHP function to uppercase the first character of each word in a string.

PHP Code:
<?php
$STRING 
"hello, i love php.";
$STRING ucwords($STRING);
echo 
$STRING;
?>
The output of the above code will be:

Code:
Hello, I Love Php.
Similarly we can use the above function at anywhere in PHP as required. 

No comments:

Post a Comment