fork download
  1. <?php
  2.  
  3. $current = 'admin/users/{type}/{id}/changePassword';
  4. $parameters = array('type' => 'administrators', 'id' => '1');
  5.  
  6. $path = preg_replace_callback('~\{(?!id\})([a-z]+)\}~i', function ($m) use ($parameters) {
  7. return $parameters[$m[1]];
  8. }, $current);
  9.  
  10. echo $path;
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
admin/users/administrators/{id}/changePassword