3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_lang = array('a'=>'a harfi','b'=>'b harfi'); $c = 'Hello world {[a]} please'; $c = preg_replace_callback('/\{\[(.*?)\]\}/', function($m) use ($_lang) { return isset($_lang[trim($m[1])]) ? $_lang[trim($m[1])] : $m[1]; }, $c); echo $c;

preferences:
56.73 ms | 402 KiB | 5 Q