Solved

partial decapitalize

Posted on 2007-11-13
5
515 Views
Last Modified: 2008-02-01
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
Comment
Question by:ed987
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 28

Expert Comment

by:gamebits
ID: 20277002
$string = "HI GUYS. HOW ARE       YOU ";

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

print $string;
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20277003
$bar = "HI GUYS. HOW ARE YOU";
$bar = ucwords(strtolower($bar));
echo $bar;

hope this helps.
0
 
LVL 17

Expert Comment

by:nplib
ID: 20277007
$str = "HI GUYS. HOW ARE YOU";

$str = strtolower($str);

$str = ucwords($str);

echo $str;

//Output will be "Hi Guys. How Are You"
0
 
LVL 7

Author Comment

by:ed987
ID: 20277029
i asked for partial decapitalize, not partial capitalize
lowercase remains lowercase
HELLO guys - > Hello guys

0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20277068
Hmmmm ....
try this

$str = "HELLO guys. HOW ARE";


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

print $str;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question