PHP 4.0 Bug #8597 Updated: problem in str_replace

From: Date: Mon, 08 Jan 2001 16:01:30 +0000
Subject: PHP 4.0 Bug #8597 Updated: problem in str_replace
Groups: php.dev 
Request: Send a blank email to php-dev+get-43394@lists.php.net to get a copy of this message
ID: 8597 Updated by: cynic Reported By: jeff@procata.com Old-Status: Open Status: Closed Bug Type: *Function Specific Assigned To: Comments: this, though it may not be deemed as the most intuitive behavior, is the intended one. $a = array( 'aa' , 'bb' , 'cc' ) ; echo str_replace("{$a[1]}", "Replaced", "abc {aa} xyz"); will produce "abc {Replaced} xyz", whereas echo str_replace("$a[1]", "Replaced", "abc {aa} xyz"); would produce a parse error. escape the braces. Previous Comments: --------------------------------------------------------------------------- [2001-01-08 10:56:24] jeff@procata.com The following code: $key = "test"; echo str_replace("{$key}", "Replaced", "abc {test} xyz"); produces incorrect output: abc {Replaced} xyz where the equivelant code: echo str_replace("{test}", "Replaced", "abc {test} xyz"); produces the correct output: abc Replaced xyz --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8597

« previous php.dev (#43394) next »