composer require pjpawel/parse-url
Comparison with parse_url() -> Conversions
Full usage you will find here -> Wiki
<?php
use pjpawel\UrlParser;
$url = "www.malformed_url.com";
$parsedUrl = UrlParser::parse($url);
var_dump($parsedUrl);
/*
array(1) {
["host"]=>
string(21) "www.malformed_url.com"
}
*/
echo UrlParser::createUrl($parsedUrl)
/*
www.malformed_url.com
*/
Output array of URL::parse()
is the same as parse_url()