Working out the image path...
| From: | Mag | Date: | Mon, 11 Oct 2004 16:50:28 +0000 |
| Subject: | Working out the image path... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-199208@lists.php.net to get a copy of this message | ||
Hey!
Am having a little problem working out the logic in
this, basically I pass a graphics path to a function
and it should give/retrun me the URL path.
<?php
$url='http://x.com/t1/t2/t3/blah.html';
function ret_url($rel_path)
{ }
?>
so I pass a relitive url like this
$a=ret_url('/blah.jpg';)
and (using the above sample url) it should return me:
http:// www.x.com/blah.jpg, which seems easy enough
except that there are some other combinations...
So far these are the combinations I could think of
that will be used...correct me if I am wrong by adding
or subtracting:
/blah.jpg // should return http://x.com/blah.jpg
/imgs/blah.jpg // return http://x.com/imgs/ blah.jpg
imgs/blah.jpg //return
http://x.com/t1/t2/t3/imgs/blah.jpg
../imgs/blah.jpg // etc
/../imgs/blah.jpg //etc
http://some-site-blah.com/imgs/blah.jpg //
return the
same url
To try and do the above I was fooling around with
parse_url() and explode() but cant work out the logic,
if it helps, heres what i did so far in my
"experiments"
$parsed_url = parse_url($url);
$thissite = $parsed_url['host'];
$thispath = $parsed_url['path'];
echo "$thissite <br> $thispath<br>";
$pieces= explode("/",$thispath);
print_r($pieces);
ANY help appreciated.
Thanks!
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail