3v4l.org

run code in 300+ PHP versions simultaneously
<?php define(DS, '/'); $server_path = "/test1/test2/"; $server_path = str_replace(array('/', '\\'), DS, $server_path); $next_server_path = substr($server_path, 0, strrpos($server_path, DS)); var_dump($next_server_path); $server_path = "/test1/test2"; $server_path = str_replace(array('/', '\\'), DS, $server_path); $next_server_path = substr($server_path, 0, strrpos($server_path, DS)); var_dump($next_server_path);

preferences:
47.56 ms | 402 KiB | 5 Q