so I am trying to learn some string functions in PHP and came across a scenario I cannot figure out. I want to take a string like such: /var/www/html and remove everything after the last forward slash (including the forward slash) so I end up with /var/www
What would be the best way to go about this?
Try using
dirname. It may handle special cases for you that you may not have anticipated if you went with a string manipulation route.