我在其中一个文件中使用了带有以下preg_replace的框架,它给了我一个错误:
[Deprecated] preg_replace():不推荐使用/ e修饰符,使用 改为preg_replace_callback
有人可以建议我如何修改它以使用preg_replace_callback吗?
$search = array(
'/\s+>\s+/', // Matches any element that is a child of parent.
'/\s+\+\s+/', // Matches any element that is an adjacent sibling.
'/\s+/', // Matches any element that is a descendant of an parent element element.
'/(\w)\[(\w+)\]/', // Matches element with attribute
'/(\w)\[(\w+)\=[\'"]?(\w+)[\'"]?\]/', // Matches element with EXACT attribute
'/(\w+)?\#([\w\-]+)/e', // Matches id attributes
'/(\w+|[\*\]])?((\.[\w\-]+)+)/e', // Matches class attributes
);
$replace = array(
'/',
'/following-sibling::*[1]/self::',
'//',
'\\1[@\\2]',
'\\1[@\\2="\\3"]',
"(strlen('\\1') ? '\\1' : '*').'[@id=\"\\2\"]'",
"(strlen('\\1') ? '\\1' : '*').'[contains(concat(\" \",@class,\" \"),concat(\" \",\"'.implode('\",\" \"))][contains(concat(\" \",@class,\" \"),concat(\" \",\"',explode('.',substr('\\2',1))).'\",\" \"))]'",
);
$xpathcache[$xpathkey] = '//'.preg_replace($search,$replace,$css_selector);
谢谢