Parsing a URL - Php Question

Posted by Adi Mathur on Stack Overflow See other posts from Stack Overflow or by Adi Mathur
Published on 2011-01-31T23:21:38Z Indexed on 2011/01/31 23:26 UTC
Read the original article Hit count: 351

Filed under:
|
|

I am using the Following code

<?php
$url = 'http://www.ewwsdf.org/012Q/rhod-05.php?arg=value#anchor';
$parse = parse_url($url);
$lnk= "http://".$parse['host'].$parse['path'];
echo $lnk;
?>

This is giving me the output as

http://www.ewwsdf.org/012Q/rhod-05.php

How can i modify the code so that i get the output as

http://www.ewwsdf.org/012Q/

Just need the Directory name without the file name

( I actually need the link so that i can link up the images which are on the pages, By appending the link behind the image Eg http://www.ewwsdf.org/012Q/hi.jpg )

© Stack Overflow or respective owner

Related posts about php

Related posts about parsing