Uppercase first letter of each new line?
| From: | Keikonium | Date: | Wed, 27 Feb 2008 21:13:58 +0000 |
| Subject: | Uppercase first letter of each new line? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-270415@lists.php.net to get a copy of this message | ||
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 :).