note 93831 added to function.preg-replace
| From: | info at gratisrijden dot nl | Date: | Fri, 02 Oct 2009 02:48:33 +0000 |
| Subject: | note 93831 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-161212@lists.php.net to get a copy of this message | ||
if you are using the preg_replace with arrays, the replacements will apply as subject for the
patterns later in the array. This means replaced values can be replaced again.
Example:
<?php
$text = 'We want to replace BOLD with the <boldtag> and OLDTAG with the
<newtag>';
$patterns = array('/BOLD/i', '/OLDTAG/i');
$replacements = array('<boldtag>', '<newtag>');
echo preg_replace ($patterns, $replacements, $text);
?>
Output:
We want to replace <b<newtag>> with the <<b<newtag>>tag> and
<newtag> with the <newtag>
Look what happend with BOLD.
----
Server IP: 69.147.83.197
Probable Submitter: 77.165.159.83
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/93831
Del: integrated -- https://master.php.net/note/delete/93831/integrated
Del: useless -- https://master.php.net/note/delete/93831/useless
Del: bad code -- https://master.php.net/note/delete/93831/bad+code
Del: spam -- https://master.php.net/note/delete/93831/spam
Del: non-english -- https://master.php.net/note/delete/93831/non-english
Del: in docs -- https://master.php.net/note/delete/93831/in+docs
Del: other reasons-- https://master.php.net/note/delete/93831
Reject -- https://master.php.net/note/reject/93831
Search -- https://master.php.net/manage/user-notes.php