I have a delete button on my page, that delete button has to delete a certain entry in my database (not too difficult), it has to delete the entire folder where the file that holds the delete button is in (also doable), but I also want it to delete another folder that’s placed somewhere else and I’m not sure how to do that. Using
dirname(__FILE__);
I am able to get the filepath where the file holding the delete button is located. That results in this:
mywebsite.nl/subdomains/dongen/httpdocs/s-gravenmoer/aandrijvingenenbesturingen/logo4life
The filepath that I also want to delete is quite similair, but a little different. The last 3 folders a variable, so their lenght (in characters) is always different. However, the second to last folder has to be deleted from this filepath so this remains:
mywebsite.nl/subdomains/dongen/httpdocs/s-gravenmoer/logo4life
Is there a way to do this with PHP? Using substr or something like that perhaps?
Thanks!
I think this should do the trick: