How to build a url path from raw path and arguments?
I don't think core has a function like that but it's easy enough to write a simple version:

$path = '/path/to/page/%foo/%bar/view/%';
$args = array('foo1', 'foo2', 'foo3');

$wildcards = array();
foreach (explode('/', $path) as $part) {
  if (strpos($part, '%') === 0) {
    $wildcards[] = $part;
  }
}

if (count($args) != count($wildcards)) {
  // Handle it
}

foreach ($args as $key =&gt; $arg) {
  $wildcard = $wildcards[$key];
  $pos = strpos($path, $wildcard);
  if ($pos === FALSE) {
    break;
  }

  $path = substr_replace($path, $arg, $pos, strlen($wildcard));
}
print $path;


Result is: /path/to/page/foo1/foo2/view/foo3