fork(1) download
  1. <?php
  2.  
  3. // your code goes here
  4. $formula = '[Spaledar] $v0 $v1 - $v2';
  5. $vars = ["v0"=>"Connected","v1"=>"Viet Name","v2"=>"Hebus jifo"];
  6.  
  7. echo "\n $formula";
  8.  
  9. $replaced = preg_replace_callback("/\$(v\d+)/", function ($tokens) use ($vars){
  10. echo "\n".$tokens[1];
  11. return $vars[$tokens[1]];
  12. }, $formula);
  13. echo "\n $replaced";
Success #stdin #stdout 0.03s 26152KB
stdin
Standard input is empty
stdout
 [Spaledar] $v0 $v1 - $v2
 [Spaledar] $v0 $v1 - $v2