title: preg_replace() relative paths to absolute path. (Masking?)
body: <p>I am in the process of trying to figure out how to mask a path over relative paths. This is a custom minifier script I'm implementing for CSS files, and need to absolute the relative paths.</p>
  
  <p>So say I have the following in a CSS file <code>url('../images/file.jpg')</code> This file is sitting in the directory <code>/application/module/assets/css/theme.css</code>, this would mean the new path in the CSS file would need to be <code>/application/module/assets/images/file.jpg</code>.</p>
  
  <p>Now say there is a CSS file in <code>/application/plugins/pluginName/assets/css/plugin.css</code> and links to <code>../../../../module/assets/images/image.jpg</code>, the replaced path would need to be <code>/application/module/assets/images/file.jpg</code></p>
  
  <p>So I'm asking, is there a nice preg_replace setup I can use to do this:</p>
  
  <pre><code>str_replace('../', '/path/to/file/', $file);
  str_replace('../../', '/path/to/', $file);
  str_replace('../../../', '/path/', $file);
  </code></pre>
  
  <p>Hopefully this makes sense...</p>
  
  <p>Regards,<br>
  Andrew</p>