ok so im making a file system viewer.
Im stuck on this though, I have everything working fine except when the I click the back button on the gui I have made.
So I have a string like so
http://www.grubber.co.nz/update/index.php?dir=../developer/_social_development
The script will go to the folder /developer/_social_development
but when I want to go back I press the back button and it will go back to the top directory so it goes all the way back to the first ‘/’ for example http://www.grubber.co.nz/update/index.php?dir=../
I use this code to get back to the last page which doesn’t work
$dir = $_GET['dir'];
$marker = "/";
echo $str = (substr($dir, 0, (strpos($dir, $marker) + strlen($marker))));
all it does is remove everthing to the first ‘/’ but I want it to goto the last ‘/’ for example it was this /developer/_social_development and when I click on the previous folder i want it to be /developer also the string will change depending on what folder you are in so I cant just remove a set amount of characters
Thanks for the help
Using another method str pos, you may use explode. here complete code:
result: ../developer