How i can check in php if the url contains xml of json file. so in the $url holds the url and than it should check whethere it is a xml file or a json file.
$url = 'http://hello.asdasd/asdasd/asdasd';
if (($url == JSON) = TRUE){ // how to check it is a json file, do the follwing action
$xml = file_get_contents($url);
$json = json_decode($xml, true);
}
else if ($url == XML) = TRUE){ // how to check it is a XML file, do the follwing action
$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
}
Any advice will be really appreciable.