Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 523
  • Last Modified:

partial decapitalize

decapitalize non first letters:
eg. HI GUYS. HOW ARE       YOU -> Hi Guys. How Are       You
spacing "\t\r\n " should remain same

could do it myself, rushing to sleep
0
ed987
Asked:
ed987
1 Solution
 
gamebitsCommented:
$string = "HI GUYS. HOW ARE       YOU ";

$string = ucfirst(strtolower($string));

print $string;
0
 
nizsmoDeveloperCommented:
$bar = "HI GUYS. HOW ARE YOU";
$bar = ucwords(strtolower($bar));
echo $bar;

hope this helps.
0
 
nplibCommented:
$str = "HI GUYS. HOW ARE YOU";

$str = strtolower($str);

$str = ucwords($str);

echo $str;

//Output will be "Hi Guys. How Are You"
0
 
ed987Author Commented:
i asked for partial decapitalize, not partial capitalize
lowercase remains lowercase
HELLO guys - > Hello guys

0
 
steelseth12Commented:
Hmmmm ....
try this

$str = "HELLO guys. HOW ARE";


$str = preg_replace("/([A-Z]+)/e","ucwords(strtolower('\\1'))",$str);

print $str;
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now