note 74991 deleted from function.str-replace by felipe

From: Date: Sun, 23 Mar 2008 23:05:29 +0000
Subject: note 74991 deleted from function.str-replace by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137421@lists.php.net to get a copy of this message
Note Submitter: yakasha ---- As the documentation states, remember that arrays are processed in order, take care to not replace your replacements: <?php $s = 'apple\'s'; $f = array('\'', '\\'); $r = array('\\\'', '\\\\'); echo str_replace($f, $r, $s); // Produces: apple\\'s $f = array('\\', '\''); $r = array('\\\\', '\\\''); echo str_replace($f, $r, $s); // Produces: apple\'s ?>

« previous php.notes (#137421) next »