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. Link to comment https://forums.phpfreaks.com/topic/43920-solved-help-with-this-please/ 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 Link to comment https://forums.phpfreaks.com/topic/43920-solved-help-with-this-please/#findComment-213228 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? Link to comment https://forums.phpfreaks.com/topic/43920-solved-help-with-this-please/#findComment-213231 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 Link to comment https://forums.phpfreaks.com/topic/43920-solved-help-with-this-please/#findComment-213233 Share on other sites More sharing options...
emehrkay Posted March 23, 2007 Share Posted March 23, 2007 edit, wrong info Link to comment https://forums.phpfreaks.com/topic/43920-solved-help-with-this-please/#findComment-213234 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. Link to comment https://forums.phpfreaks.com/topic/43920-solved-help-with-this-please/#findComment-213496 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.