Saturday, 4 November 2017

How do i reverse parse_url in PHP


$parsed = parse_url($url);

You can reverse back parse url like below

$newUrl = $parsed['scheme']."://".$parsed['host'].$parsed['path'];
$new_query = http_build_query($params);
if($new_query){
    $newUrl .= "?".$new_query;
}

No comments: