ID:               22886
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ekomhadi at yahoo dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         PCRE related
 Operating System: Linux
 PHP Version:      4.3.0
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

$0 and $1 are not valid variable names and in case of regex they are
treated like $0 (entire matched string) and $1 1st matched element.


Previous Comments:
------------------------------------------------------------------------

[2003-03-25 22:23:08] ekomhadi at yahoo dot com

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 this bug report at http://bugs.php.net/?id=22886&edit=1

Reply via email to