If you use jsonlint to validate the response of the url directly from browser you will find that the output is not a valid json response. hence you are unable to decode it. All you need to do is remove html tags which are hidden and hotel_id content and and issues with new lines . After solving those issues it becomes a valid json response. and there you go.
<?php $base_url = "https://www.the-worldwide.com/wp-content/themes/thewebconz/Live-6-cid/functions.php"; $data = [ "action" => "Hotel_Description", "hotel_id" => 438271, "cid" => 457428, ]; $config = [ "apiKey" => "5jjdvgnq9aug1a4ucvatvq4b8u", "ModeType" => "Live", "secret" => "9hs897nn3e9av" ]; function buildUrl($base_url, $data, $config) { $url = $base_url."?"; $data_uri = ""; foreach ($data as $data_key => $data_value) { $data_uri .= "$data_key=$data_value&"; } $config_uri = ""; foreach ($config as $config_key => $config_value) { $config_uri .= "$config_key=$config_value&"; } $url= $base_url."?".$data_uri.rtrim($config_uri, "&"); unset($data_uri); unset($config_uri); return $url; } $url = buildUrl($base_url, $data, $config); $content = file_get_contents($url); $new_content = str_replace("<HotelInformationRequest><hotelId>".$data['hotel_id']."</hotelId><options>0</options></HotelInformationRequest>", "", $content); $json_content = str_replace("\n", " ", $new_content);