[pmwiki-users] Help with preg_replace/e

Petko Yotov 5ko at 5ko.fr
Tue Feb 25 17:44:54 CST 2014


Vince Administration writes:
> In trying to convert UpdateForm to be PHP 5.5 compatible, I ran into the last  
> line of the original recipe -- The last three lines are:
>
> //exit code copied bodily from forms.php
>   $FmtV['$UpdateFormArgs'] = implode(' ', $attr);
>   $out .= FmtPageName($opt[':html'], $pagename);
>   return preg_replace('/<(\\w+\\s)(.*)$/es',"'<$1'.Keep(PSS('$2'))", $out);

The following code should work in both PHP 5.5 and earlier, and in both PmWiki  
2.2.58 and earlier (last line only):

  return preg_replace_callback('/<(\\w+\\s)(.*)$/s',
     create_function('$m', "return '<'.\$m[1].Keep(\$m[2]);"),
     $out);

See the pages http://php.net/preg_replace_callback and  
http://php.net/create_function for more information.

Petko




More information about the pmwiki-users mailing list