note 84506 added to function.preg-replace

From: Date: Wed, 16 Jul 2008 22:23:29 +0000
Subject: note 84506 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-141597@lists.php.net to get a copy of this message
When you use the '$1', '$2', etc. replacement values, they can be either in double or single quotes. There is no need to worry about the dollar sign being interpreted as a variable or not: <?php print preg_replace("/I want (\S+) one/", "$1 is the one I want", "I want that one") . "\n"; print preg_replace("/I want (\S+) one/", '$1 is the one I want', "I want that one") . "\n"; ?> Both lines will print "that is the one I want". ---- Server IP: 209.41.74.194 Probable Submitter: 8.11.253.196 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/84506 Del: integrated -- https://master.php.net/note/delete/84506/integrated Del: useless -- https://master.php.net/note/delete/84506/useless Del: bad code -- https://master.php.net/note/delete/84506/bad+code Del: spam -- https://master.php.net/note/delete/84506/spam Del: non-english -- https://master.php.net/note/delete/84506/non-english Del: in docs -- https://master.php.net/note/delete/84506/in+docs Del: other reasons-- https://master.php.net/note/delete/84506 Reject -- https://master.php.net/note/reject/84506 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141597) next »