note 74991 added to function.str-replace
| From: | yakasha at osu1 dot php dot net | Date: | Mon, 07 May 2007 21:01:51 +0000 |
| Subject: | note 74991 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126298@lists.php.net to get a copy of this message | ||
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
?>
----
Server IP: 64.71.164.2
Probable Submitter: 204.16.153.50
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/74991
Del: integrated -- https://master.php.net/note/delete/74991/integrated
Del: useless -- https://master.php.net/note/delete/74991/useless
Del: bad code -- https://master.php.net/note/delete/74991/bad+code
Del: spam -- https://master.php.net/note/delete/74991/spam
Del: non-english -- https://master.php.net/note/delete/74991/non-english
Del: in docs -- https://master.php.net/note/delete/74991/in+docs
Del: other reasons-- https://master.php.net/note/delete/74991
Reject -- https://master.php.net/note/reject/74991
Search -- https://master.php.net/manage/user-notes.php