阅读背景:

Php Regex - 如果等于某事,如何选择

来源:互联网 
class Something

{

    public static function compile(&$subject, $replace, $with) {

        $placeholders = array_combine($replace, $with);



        $condition  = '{[a-z0-9\_\- ]+:[a-z_]+}';

        $inner      = '((?:(?!{/?if).)*?)';     

        $pattern    = '#{if\s?('.$condition.')}'.$inner.'{/if}#is';



        while (preg_match($pattern, $subject, $match)) {

            $placeholder = $match[1];           

            $content     = $match[2];



    // if empty value remove whole line

    // else show line but remove pseudo-code

    $subject = preg_replace($pattern,

                            empty($placeholders[$placeholder]) ? '' : addcslashes($content, '$'),

                            $subject,

                            1);

        }

    }

}
class Something

{

    public static function 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: