Hi,

In my $str="DAniweb it DISCUSSION Community"
I want "Each First" character is capital and rest of lower case "

If String is
$str="DAniweb it DISCUSSION Community"

Ans-> Daniweb It Discussion Community

How to do this??

Yayo, that'd output:

"DAniweb It DISCUSSION Community"

You need to use strtolower(), and ucwords(). strtolower() makes all characters in a string lowercase; ucwords() capitalizes the first letter of each word in a string.

<?php

$str="DAniweb it DISCUSSION Community"
$str = strtolower($str);
$str = ucwords($str);

?>

or

<?php

$str ="DAniweb it DISCUSSION Community"
$str = ucwords(strtolower($str));
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.