Webmozart\PathUtil\Url::split PHP Méthode

split() private static méthode

php list ($root, $path) = Path::split("http://example.com/webmozart") => array("http://example.com", "/webmozart") list ($root, $path) = Path::split("http://example.com") => array("http://example.com", "")
private static split ( string $url ) : string[]
$url string The URL to split.
Résultat string[] An array with the host and the path of the URL.
    private static function split($url)
    {
        $pos = strpos($url, '://');
        $scheme = substr($url, 0, $pos + 3);
        $url = substr($url, $pos + 3);
        if (false !== ($pos = strpos($url, '/'))) {
            $host = substr($url, 0, $pos);
            $url = substr($url, $pos);
        } else {
            // No path, only host
            $host = $url;
            $url = '/';
        }
        // At this point, we have $scheme, $host and $path
        $root = $scheme . $host;
        return array($root, $url);
    }