|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-09-03 21:04 UTC] jani@php.net
[2009-09-03 21:58 UTC] d dot reade at readesresidential dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 13:00:01 2025 UTC |
Description: ------------ Trying to use preg_replace to change text to uppercase in-between <uc><uc>. However expected result doesn't occur and the text remains lowercase. No errors are logged. However adding some text after $1 outputs this text in uppercase, but the text in-between <uc><uc> remains as lowercase. Reproduce code: --------------- <? # Test 1: Attempt to replace 'my' with 'MY' $text = 'this is <uc>my<uc> string'; $text = preg_replace('/\<uc\>(.*)\<uc\>/', strtoupper('$1'), $text); echo $text.'<br><br>'; # Test 2: Add something after $1 which produces expected output $text = 'this is <uc>my<uc> string'; $text = preg_replace('/\<uc\>(.*)\<uc\>/', strtoupper('$1 cool'), $text); echo $text; ?> Expected result: ---------------- # Expected result for test 1 this is MY string # Expected result for test 2 this is MY COOL string Actual result: -------------- # Actual result for test 1 this is my string # Actual result for test 2 this is my COOL string