1 2 3 4 5 6 7
<?php $str = "hi,this is a test"; $test = "string test"; echo preg_replace("(,\w*)","$test",$str); echo "\n\n"; $str = "hi,this is a test"; echo preg_replace("(,\w*)","$1",$str);
1 2 3
histring test is a test hi is a test