3v4l.org

run code in 300+ PHP versions simultaneously
<?php $path = "/var/log/apache/foo/bar"; // let's remove the last two folders from the path echo substr($path, 0, strrpos($path, '/', strrpos($path, '/') - strlen($path)));

preferences:
28.29 ms | 405 KiB | 5 Q