preg replace - Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead -


i need little help. because preg_replace deprecated, have convert preg_replace preg_replace_callback...

function parse_bb_tpl ($part, $args) {     // replace, evaluation...     return preg_replace (         '/{([^}\s]+)}/e',         "isset (\$args['\\1']) ? \$args['\\1'] : '';",         $this->_tpls[$part]     ); } 

casimir correct ... e modifier being depricated. preg_replace_callback pretty cool, though. basically, make function gets fed matches , use doing evaluation.

$string = 'the bat batty in bathroom';  $string = preg_replace_callback('/bat/', 'cool_function', $string);  print $string;  function cool_function($matches) {     return '<b>'.$matches[0].'</b>';     } 

that outputs this:

the <b>bat</b> <b>bat</b>ty in <b>bat</b>hroom 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -