Re: Uppercase first letter of each new line?
| From: | Daniel Brown | Date: | Wed, 27 Feb 2008 21:24:04 +0000 |
| Subject: | Re: Uppercase first letter of each new line? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-270419@lists.php.net to get a copy of this message | ||
On Wed, Feb 27, 2008 at 4:13 PM, Keikonium <Keikonium@hotmail.com> wrote:
[snip!]
> 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.
[snip!]
Here's a function to help you out. It's also online here:
[Demo] http://www.pilotpig.net/code-library/capitalize-line.php
[Source]
http://www.pilotpig.net/code-library/source.php?f=capitalize-line.php
function ucnewline($str) {
$arr = explode("\n",$str);
foreach($arr as $p) {
$ret .= ucfirst($p)."\n";
}
return $ret;
}
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>