3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $server_path = "/test1/test2/"; $server_path = str_replace(array('/', '\\'), '/', $server_path); var_dump($server_path); $next_server_path = substr($server_path, 0, strrpos($server_path, '/')); var_dump($next_server_path); $server_path = "/test1/test2"; $server_path = str_replace(array('/', '\\'), '/', $server_path); var_dump($server_path); $next_server_path = substr($server_path, 0, strrpos($server_path, '/')); var_dump($next_server_path);
based on ntnuQ
Output for 4.3.0 - 7.1.0
string(13) "/test1/test2/" string(12) "/test1/test2" string(12) "/test1/test2" string(6) "/test1"