note 115660 added to function.str-replace
| From: | Ing.MirkoPlazotta | Date: | Thu, 04 Sep 2014 09:27:18 +0000 |
| Subject: | note 115660 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200365@lists.php.net to get a copy of this message | ||
<?php
// a very beatiful way to do multiple replacements is this one, using just one array
$replaceThis = Array(
'old word' => 'new word',
'was' => 'it',
'past' => 'future',
);
$originalText = "every old word was a thing of the past...";
$replacedText = str_replace(array_keys($replaceThis), $replaceThis, $originalText);
echo $replacedText;
?>
----
Server IP: 91.118.111.7
Probable Submitter: 85.124.35.237
----
Manual Page -- http://php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/115660
Del: integrated -- https://master.php.net/note/delete/115660/integrated
Del: useless -- https://master.php.net/note/delete/115660/useless
Del: bad code -- https://master.php.net/note/delete/115660/bad+code
Del: spam -- https://master.php.net/note/delete/115660/spam
Del: non-english -- https://master.php.net/note/delete/115660/non-english
Del: in docs -- https://master.php.net/note/delete/115660/in+docs
Del: other reasons-- https://master.php.net/note/delete/115660
Reject -- https://master.php.net/note/reject/115660
Search -- https://master.php.net/manage/user-notes.php