parse url php
snippet in php

parse url php

user5044

var_dump(parse_url($url)); 
var_dump(parse_url($url, PHP_URL_SCHEME)); 
var_dump(parse_url($url, PHP_URL_QUERY)); 

part of url php

user3620

    //https://www.google.com/search?key=1234
	$url = $_SERVER['REQUEST_URI']; 
    $url_components = parse_url($url); 
    parse_str($url_components['query'], $params); 
    $key = $params['key']; 

// key=1234

how to split url in php

user8793

<?php
$url = 'http://www.example.com/news?q=string&f=true&id=1233&sort=true';

$values = parse_url($url);

$host = explode('.',$values['host']);

echo $host[1];

?>