How to split a url in php

  • 0

How to split a website url in php?

Using parse_url() function you can split the URL in php

$url_str=parse_url(‘http://www.thehindu.com/news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece’);

print_r($url_str);

 

Answer will be :

(
    [scheme] => http
    [host] => www.thehindu.com
    [path] => /news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece
)

How to split a website url in php? Using parse_url() function you can split the URL in php $url_str=parse_url(‘http://www.thehindu.com/news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece’); print_r($url_str);   Answer will be : ( [scheme] => http [host] => www.thehindu.com [path] => /news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece )

How to split a website url in php? Using parse_url() function you can split the URL in php $url_str=parse_url(‘http://www.thehindu.com/news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece’); print_r($url_str);   Answer will be : ( [scheme] => http [host] => www.thehindu.com [path] => /news/national/highlights-from-prime-ministers-lok-sabha-speech-targeting-congress/article22678689.ece )