From: [EMAIL PROTECTED]
Operating system: linux debian
PHP version: 4.2.3
PHP Bug Type: *General Issues
Bug description: str_replace behaves strangely, not replacing valid key/val pairs
i have a template engine running, in it a string (content hereon) with keys
and an array (parsevals hereon) with key/values that need to be replaced
in the content
this is what i do:
foreach ($this->_parsevals as $key=>$val) {
$retval = str_replace('{'.$key.'}',$val,$retval);
}
after that i do a preg_match_all to find all the remaining keys in the
content with this regexp: '/\{[A-Za-z][-_A-Za-z0-9]*\}/', and find
existing keys, which also exist in $this->_parsevals..
if (preg_match_all($this->regex_var,$retval,$result)) {
foreach ($result[0] as $val) {
$key = substr($val,1,-1);
if (isset($this->_parsevals[$key])) {
condor_assert($key." exists in parsevals?!?!?");
$retval = str_replace($val,
$this->_parsevals[$key],$retval);
}
}
}
condor_assert is a basic log function, and its activated with that error
message in there... another str_replace seems to solve the problem of the
"undefined variable" case..
i tried to reproduce this in a short-self-contained script but failed, i
will test it on 4.3 asap
--
Edit bug report at http://bugs.php.net/?id=21287&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=21287&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=21287&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=21287&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=21287&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=21287&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=21287&r=support
Expected behavior: http://bugs.php.net/fix.php?id=21287&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=21287&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=21287&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=21287&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21287&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=21287&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=21287&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=21287&r=gnused