Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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