preg replace - Why preg_replace() function isn't working properly? -
my php script is:
<?php $string = '{controller}/{action}'; $pattern = '/\{([a-z]+)\}/i'; $replacement = '(?p<$1>[a-z-]+)'; echo preg_replace($pattern, $replacement, $string); ?>
it showing result:
(?p[a-z-]+)\/(?p[a-z-]+)
i expecting this:
(?p<controller>[a-z-]+)\/(?p<action>[a-z-]+)
how can able this??
Comments
Post a Comment