tcorbeil Posted March 23, 2007 Share Posted March 23, 2007 Someone gave me this script to use: list(,$dir) = split("/", $_SERVER['SCRIPT_NAME']); basically what it does is this: If i have a path that is something like /oilers/oiler.php the above script removes the oilers.php part so that all remains is /oilers but... I have a problem if the path exceeds more than 1 dash .. ex /sports/hockey/oilers/oilers.php what remains is /sports... i need the whole link minus the running file.. eg, /sports/hockey/oilers ... Any idea as to how i could do this? Thanks T. Quote Link to comment Share on other sites More sharing options...
emehrkay Posted March 23, 2007 Share Posted March 23, 2007 well you can easily explode it by "/" and use the array key to get to the result $arr = expolde("/", $str); $arr[0] = 'sports'; $arr[1] = 'hockey'; etc etc Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted March 23, 2007 Author Share Posted March 23, 2007 emehrkay, thanks.. but the link is not always going to be the same thing.. Would this still work?? And also, the amount of dashes in the link may vary aswell... can i still make this work somehow? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 23, 2007 Share Posted March 23, 2007 You can also use the pathinfo() function: <?php $pi = pathinfo($_SERVER['SCRIPT_NAME']); echo $pi['dirname']; ?> Ken Quote Link to comment Share on other sites More sharing options...
emehrkay Posted March 23, 2007 Share Posted March 23, 2007 edit, wrong info Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted March 23, 2007 Author Share Posted March 23, 2007 Hey kenrbnsn, your script worked very well, thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.