From:             ekomhadi at yahoo dot com
Operating system: Linux
PHP version:      4.3.0
PHP Bug Type:     PCRE related
Bug description:  preg_replace $0 and $1

I'm using PHP 4.3.0
I found problem when using preg_replace(..)
string $0 and $1 will mess up and not replace correctly
also $N with N is Integer will not appear. If the character after the
dollar sign is not a number, it works as expected.

Here is my code:
<?php
/*** PHP START***/
// Found: 26-03-2003

$strBuffer=
'
<pre>
----------------------
preg_replace() bug???
----------------------
<LOOP>
[NUMBER]         [MESG]
</LOOP>
----------------------
</pre>
';
$strNumber = 123456789;
$strMesg   = "text with $0 and $1 string";

$Patttern = "/<LOOP>(.*?)<\/LOOP>/is";
preg_match($Patttern, $strBuffer, $arrTag);
$strData  = str_replace("[NUMBER]",   $strNumber, $arrTag[1]);
$strData  = str_replace("[MESG]",     $strMesg,   $strData);
$strBuffer= preg_replace($Patttern, $strData, $strBuffer);
echo $strBuffer;

/*** PHP END***/
?>
-- 
Edit bug report at http://bugs.php.net/?id=22886&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22886&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22886&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22886&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22886&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22886&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22886&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22886&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22886&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22886&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22886&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22886&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22886&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22886&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22886&r=gnused

Reply via email to