Monday 9 July 2012

Usage of preg_replace, search and replace {variable}


Regular Expression: Usage of preg_replace, search and replace {variable}, {variable_one} and join{string_var_able}.
$string = "This {variable} will be {variable_with_underscore}  and {variable}with will be replaced";
$pattern = array('/($|\{(\w+))\}/'); 
$replace = array('...'); 
$string = preg_replace($pattern, $replace, $string);

No comments:

Post a Comment

Please post any queries and comments here.