0
$search = array('/(\w+)?\#([\w\-]+)/e','/(\w+|[\*\]])?((\.[\w\-]+)+)/e',);
$replace = array('(strlen('\\1') ? '\\1' : '*').'[@id=\"\\2\"]'','(strlen('\\1') ? '\\1' : '*').'[contains(concat(\" \",@class,\" \"),concat(\" \",\"'.implode('\",\" \"))][contains(concat(\" \",@class,\" \"),concat(\" \",\"',explode('.',substr('\\2',1))).'\",\" \"))]',);
$selector = preg_replace($search, $replace, $css_selector);

Can you please tell me how to replace preg_replace to preg_replace_callback.

It throws me an error preg_replace_callback(): The /e modifier is no longer supported, use preg_replace_callback instead

IMSoP
  • 89,526
  • 13
  • 117
  • 169
James
  • 27
  • 3
  • Why do you want to use `preg_replace_callback`? Your code is working fine. – Toto Nov 13 '19 at 13:38
  • It throws me the below error preg_replace_callback(): The /e modifier is no longer supported, use preg_replace_callback instead – James Nov 13 '19 at 18:44
  • You've just completely modified the question! Now it's a duplicate. – Toto Nov 13 '19 at 19:23
  • Now you'll find your answer here: https://stackoverflow.com/q/15454220/372239 – Toto Nov 13 '19 at 19:24
  • Does this answer your question? [Replace preg\_replace() e modifier with preg\_replace\_callback](https://stackoverflow.com/questions/15454220/replace-preg-replace-e-modifier-with-preg-replace-callback) – IMSoP Jan 08 '21 at 10:49

0 Answers0