ID: 49459 Updated by: j...@php.net Reported By: d dot reade at readesresidential dot com -Status: Open +Status: Bogus -Bug Type: Unknown/Other Function +Bug Type: PCRE related Operating System: CentOS 5.3 x86 PHP Version: 5.2.10 New Comment:
Your forgot to RTFM: http://www.php.net/manual/en/function.preg-replace.php Hint: Example #4 Previous Comments: ------------------------------------------------------------------------ [2009-09-03 16:00:23] d dot reade at readesresidential dot com 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49459&edit=1