RE: [PHP] String replacement
| From: | Richard Heyes | Date: | Sun, 06 Aug 2000 01:29:04 +0000 |
| Subject: | RE: [PHP] String replacement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10288@lists.php.net to get a copy of this message | ||
> For example:
> Original string = "This is a string. <CAP>This part should be
> capitalized.</CAP>"
[...]
> New string = "This is a string. THIS PART SHOULD BE CAPITALIZED."
preg_match('/<CAP>(.+)<\/CAP>/U', $orig_string, $matches);
$new_string = str_replace('<CAP>'.$matches[1].'</CAP>',
strtoupper($matches[1]), $orig_string);
--
Richard Heyes
http://www.heyes-computing.net/scripts/
Plain text email only please!