Cleaner or better readability in URL composition
You could simplify to something such as:

$url = 'http://www.example.com/api/v1/all/limit/%d/offset/%d';

$newURL = sprintf($url, $limit, $offset);


We use sprintf() for this.

Update


  e (PREG_REPLACE_EVAL)
  
  Warning This feature has been DEPRECATED as of PHP 5.5.0. Relying on
  this feature is highly discouraged.


Docs

Now I really suggest you find an alternative.

According to your update, you say the number of variables might grow. Could you explain (example code?) this more? If it "grows", then the issue may not be this part of the function, it may be the surrounding code that needs fixing.