3v4l.org

run code in 300+ PHP versions simultaneously
<?php function file_uri_scheme($uri) { $position = strpos($uri, '://'); return $position ? substr($uri, 0, $position) : FALSE; } function file_uri_target($uri) { $data = explode('://', $uri, 2); // Remove erroneous leading or trailing, forward-slashes and backslashes. return count($data) == 2 ? trim($data[1], '\/') : FALSE; } function file_stream_wrapper_uri_normalize($uri) { $scheme = file_uri_scheme($uri); if ($scheme) { $target = file_uri_target($uri); if ($target !== FALSE) { $uri = $scheme . '://' . $target; } } return $uri; } $uri = 'private://test/example.exe'; echo file_stream_wrapper_uri_normalize($uri);

preferences:
43.71 ms | 402 KiB | 5 Q