Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中将cURL中的数据显示到表中?_Php_Html - Fatal编程技术网

如何在PHP中将cURL中的数据显示到表中?

如何在PHP中将cURL中的数据显示到表中?,php,html,Php,Html,我需要从一个网站获得数据,并显示在我的网站表中。我得到的数据是正确的,但现在只需要将其添加到一个表中,以便它更清晰 这是我得到的一些信息的代码: echo "<div style='font-weight: bold;'>getProvinces</div>"; $args = array(); $args["strSessionId"] = $session; $result = CurlFunction($args, "getProvinces"); echo '

我需要从一个网站获得数据,并显示在我的网站表中。我得到的数据是正确的,但现在只需要将其添加到一个表中,以便它更清晰

这是我得到的一些信息的代码:

echo "<div style='font-weight: bold;'>getProvinces</div>";

$args = array();
$args["strSessionId"] = $session;

$result = CurlFunction($args, "getProvinces");
echo '<pre>';
var_dump($result);
echo '</pre>';
我只是需要一些关于如何将上述信息放入表格的帮助。如果可能的话,只包括部分。我附上了一张图片,以显示我目前得到的信息,以及我希望以表格形式获得的数据

谢谢


链接到我正在使用的完整代码:

使用
json\u decode
获取表示响应数据的数组,并使用
foreach
循环在表中为每个数据项创建键值对

代码可能如下所示:

$jsoned=json\u解码($result,true)
?>

顺便说一句,

的快捷方式。首先,使用如下方法将
json
响应转换为数组:

然后,您可以使用响应检查,如:


现在,您可以使用
html
循环使用
$decoded['arrProvinceId']
结果

提示:我认为你需要使用json_解码,然后你可以在你的HTMLTanks中使用循环,但问题是我不知道如何在这种情况下使用它?检查答案,我希望这将帮助UI解决你的问题??不,不幸的是还没有。仍在尝试解决此问题。未定义变量jsonResponse出现错误。我不确定在哪里可以找到该变量。@KeithKing:太棒了,json响应保存在哪里?有变量吗?分享你的
curlffunction
方法的完整代码
jsonResponse
只是一个示例名称@Keithking这是我正在使用的API,所以我从网站调用json以显示在我的网页中。这是路径
https://apitest.example.co.za/“.”调用/rsapi/getProvinces.json
@KeithKing:共享此方法中的代码
curlffunction()
case "getProvinces":
    {
        $Url = "https://apitest.axxess.co.za/" . 
"calls/rsapi/getProvinces.json";
        $curl->setBasicAuthentication($Username, $Password);
        $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
        $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
        $curl->get($Url, $d);

        break;
    }
// assuming `$jsonResponse` is your json response variable
$decoded = json_decode($jsonResponse,true); // here true will use return response in array format
if($decoded['intCode'] == 200){
    print_r($decoded['arrProvinceId']); // this will return you your response in array
}