从php api返回json

I am new to programming and would like to begin adding more advanced applications to my site. I am trying to call an api with php. I'm having trouble getting it to return json format.

<?php


if(!empty($_GET['hospital_name'])) {
$Hospcomp_url = 'https://data.medicare.gov/resource/rbry-mqwu.json?hospital_name=' . urlencode($_GET['hospital_name']);

$Hospcomp_json = file_get_contents($Hospcomp_url);
json_decode($Hospcomp_json, true);
}

?>


<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CMS</title>
</head>
<body>
<form action="">

<input type="text" name="hospital_name"><br>
<input type="submit" value="Submit">

</form>
</body>
</html>

It seems, you get your result properly but you don't do anything with it. First of all, you don't assign the array decoded from JSON to a variable. And then, you don't echo or process your array otherwise.
Please replace this:

json_decode($Hospcomp_json, true);

with something like this:

$decoded = json_decode($Hospcomp_json, true);
var_export($decoded);

Then you'll have your output and you will be able to decide what to do next.

Calls are correct, just var_export it.

if(!empty($_GET['hospital_name'])) {
    $Hospcomp_url = 'https://data.medicare.gov/resource/rbry-mqwu.json?hospital_name=' . urlencode($_GET['hospital_name']);

    $Hospcomp_json = file_get_contents($Hospcomp_url);
    var_export(json_decode($Hospcomp_json, true));
}