|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-16 12:33 UTC] anton dot kirsanov at gmail dot com
Description:
------------
strtoupper(), strtolower() function does not change
string(as virtual vars - like $1(\\1)) what be returned a preg_replace function.
Reproduce code:
---------------
<?php
// 1
$s = "A-B";
echo preg_replace("/\-([a-z])/iU", strtolower("$1"), $s);
echo "\n";
// 2
$s = "a-b";
echo preg_replace("/\-([a-z])/iU", strtoupper("$1"), $s);
// 3
$s = "B-B";
echo preg_replace("/([a-z]-[a-z])/i", strtolower("A-$1-A"), $s);
?>
Expected result:
----------------
AB
ab
a-B-B-a
Actual result:
--------------
Ab
aB
abba
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 17:00:01 2025 UTC |
Hi:) funny... you will use "/e" modifier if you want parse the pattern as a php code. Say me, why a function str_repeat() really work in this situation: <?php $s = "A-B"; echo preg_replace("/\-([a-z])/iU", str_repeat("$1", 10), $s); ?> // -------------- // ACTUAL RESULT: // -------------- ABBBBBBBBBB Why? See that: <?php $s = "A-B"; echo preg_replace("/\-([a-z])/iU", strtolower(str_repeat("$1", 10)), $s); ?> // -------------- // ACTUAL RESULT: // -------------- ABBBBBBBBBB // Why that ? :)