douzhong2954 2018-05-15 22:39
浏览 50

传递多维JSON PHP结果错误

First of all id like to thanks for viewing my questions. The second, i appologize if my question are duplicate after all i searching there is no one match with my question. So here it is..

I have struggle when i want to parse the JSON data. I have try using all loops method it works but it only showing one data. Here is my json data :

{
"domain": [
{
"Domain": "countoftuscany.com",
"Created": "04/02/2018",
"IsOurDNS": "false",
"Expired": "04/02/2019"
},
{
"Domain": "gnesarssssis.com",
"Created": "04/01/2018",
"IsOurDNS": "false",
"Expired": "04/02/2019"
},
{
"Domain": "gnesarssis.com",
"Created": "04/01/2018",
"IsOurDNS": "false",
"Expired": "04/01/2019"
},
{
"Domain": "gnesarssi.com",
"Created": "04/01/2018",
"IsOurDNS": "false",
"Expired": "04/01/2019"
},
{
"Domain": "gnesarsi.com",
"Created": "04/01/2018",
"IsOurDNS": "false",
"Expired": "04/01/2019"
},
{
"Domain": "iniituadas.com",
"Created": "04/01/2018",
"IsOurDNS": "false",
"Expired": "04/01/2019"
}
],
"Perpage": "50",
"Total": "91",
"CurPage": "1"
}

Im using laravel 5.6.21 and XmlParser by orchestral on this case

The Code :

public function getList($page = null)
    {
        if (!$page) {$page = 1;}
        $cache = 'DOMAIN-'.Auth::user()->id.'-'.$page;
        if (Cache::has($cache)) {
            $hasil = Cache::get($cache);
            return $hasil;
            $data = json_decode(json_encode($hasil));
            // foreach ($data as $key) {
            //     dd($key);
            // }
            // return view('namecheap.show', compact('hasil'));
        } else {
            $url = $this->urlNc().'&Command=namecheap.domains.getList&ClientIp=119.81.31.23&PageSize=50&SortBy=EXPIREDATE_DESC&Page='.$page;
            $resp = Curl::to($url)->get();
            $xml = XmlParser::extract($resp);
            $hasil = $xml->parse([
                'domain' => ['uses' => 'CommandResponse.DomainGetListResult.Domain[::Name>Domain,::Created>Created,::IsOurDNS>IsOurDNS,::Expires>Expired]','default' => null],
            ]);
            Cache::put($cache, $hasil, 10);
            return $hasil;
            return view('namecheap.show', compact('hasil'));
        }
    }

I want to get the "domain" data and then showing all of them. Could somebody please help me ? :( Please, i have try everything i know..

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题