Reputation: 12085
How can I compute the absolute path of a file, when I've got a relative path and another absolute path which should act as an anchor point.
For example:
$anchor = '/tmp/uploads/abcd1234/import.xml';
$relative = 'main_image.png';
$abs = foo($anchor, $relative); # fn `foo` is what I'm looking for
assert($abs == '/tmp/uploads/abcd1234/main_image.png');
or slightly more complicated:
$anchor = '/tmp/uploads/abcd1234/import.xml';
$relative = '../resource/dummy.jpg';
$abs = foo($anchor, $relative); # fn `foo` is what I'm looking for
assert($abs == '/tmp/uploads/resource/dummy.jpg');
Upvotes: 0
Views: 50