Uppercase first letter of each new line?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm sure this is really easy to accomplish, but I just can't seem to figure it out. I have the following:

$str = "
mary had a little lamb
it's fleece was white as snow
and everywhere that mary went
the lamb was sure to go";

Using ucfirst($str) will only capitalize the first letter of the string (duh :P). So I tried ucwords($str) and it obviously capitalized EVERY word. Also not desired. I couldn't find a php function to capitalize each new line, so I was thinking that regex would probably be needed and I am just no good at that @_@. I was reading up about it a bit, but it's still really confusing me. I was thinking something like splitting each new line into a separate string, capitalizing the first letter with ucfirst(), and then merging the string back together might work, but I am not sure how to find a new line.

Any help would be appreciated Thank you in advance :).
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux