note 55294 deleted from function.preg-replace by tularis

From: Date: Sun, 18 Jun 2006 13:27:34 +0000
Subject: note 55294 deleted from function.preg-replace by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114316@lists.php.net to get a copy of this message
Note Submitter: skatebiker at hotmail dot com ---- Replacing a double quote in a string using the /e modifier in preg_replace() returns a backslash. $string='\'"'; echo preg_replace('/(["\'])/ie', '"[".ord(\'$1\')."]"', $string); Exprected result: [39][34] Result: [39][92] So the double quote is prepended by a backslash. A workaround is : echo preg_replace('/(["\'])/ie', '"[".ord(substr(\'$1\',-1))."]"', $string); which returns the desired result for the double quote as well.

« previous php.notes (#114316) next »