3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { private function z($matches) { var_dump($matches); switch ($matches) { case 'cool': return 'wow'; case 'hey': return 'hehe'; } } public function y($template) { echo preg_replace_callback('/\[\[\s?([^\]]+)\s?\]/', [$this, 'z'], $template); } } $x = new X(); $x->y('bla bla [[ hey ]] dasfasdf [[ cool ]] werwr');

preferences:
55.13 ms | 402 KiB | 5 Q