Re: Uppercase first letter of each new line?
| From: | Robert Cummings | Date: | Wed, 27 Feb 2008 21:24:43 +0000 |
| Subject: | Re: Uppercase first letter of each new line? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-270420@lists.php.net to get a copy of this message | ||
On Wed, 2008-02-27 at 16:13 -0500, Keikonium wrote:
> 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";
<?php
function ucCallback( $match )
{
return strtoupper( $match[0] );
}
$str = "
mary had a little lamb
it's fleece was white as snow
and everywhere that mary went
the lamb was sure to go";
echo $str."\n\n";
$str = preg_replace_callback( '/\n\r?./ms', 'ucCallback', $str );
?>
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'