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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to