You are here: Re: [PHP] sentence case « PHP « IT news, forums, messages
Re: [PHP] sentence case

Posted by Leif Gregory on 02/23/05 20:31

Hello Jay,

Wednesday, February 23, 2005, 11:05:51 AM, you wrote:
>> How can I convert sentences like this. To be upper and lower case.

J> http://www.php.net/ucfirst


That won't work because it'll only capitalize the first letter of the
string. Since his string contains more than one sentence he needs to
be able to capitalize the first letter of each sentence.

I'm thinking something like:

1. strtolower() the string
2. explode() on the period
3. Loop through the resulting array
a. trim() whitespace on each element
b. ucfirst() on each element of the array
c. Concatenate the string back together, putting a period and a
space at the end of each element.

That's the long way. Anyone know the shortcut! <grin>


--
Leif (TB lists moderator and fellow end user).

Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация