|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-03-26 09:55 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 13:00:01 2025 UTC |
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***/ ?>