使用个人名称获取json_decode的值

时间:2018-11-05 17:28:32

标签: php arrays json foreach

如何从JSON接收个人信息?

JSON:

{
   "134819":{
      "0":"WEBRip LD x264 PsO",
      "1":"1",
      "3":"134819",
      "r":{
         "t":[
            13,
            11
         ],
         "b":[
            14,
            11
         ]
      },
      "2":"WEBRip LD x264 PsO",
      "links":{
         "Streamcloud":[
            [
               "1",
               "mediabox",
               "streamcloud.ico",
               "http:\/\/streamcloud.eu\/zaxljnwu4yti\/tn-855.mkv.html",
               "81",
               "stream",
               "0"
            ]
         ],
         "Openload":[
            [
               "1",
               "redirect",
               "none",
               "https:\/\/openload.co\/f\/r9WrAB2RPdI\/tn-603.mkv",
               "123",
               "download",
               "0"
            ]
         ],
         "Share-online":[
            [
               "1",
               "redirect",
               "so.ico",
               "http:\/\/www.share-online.biz\/dl\/9HWBDGHPJ5",
               "67",
               "download",
               "1"
            ]
         ],
         "Uptobox":[
            [
               "1",
               "redirect",
               "none",
               "https:\/\/uptobox.com\/4p3yqf8bvzxv",
               "506",
               "download",
               "5"
            ]
         ],
         "Flashx":[
            [
               "1",
               "redirect",
               "none",
               "https:\/\/www.flashx.tv\/emx2759pwqef.html",
               "129",
               "stream",
               "8"
            ]
         ],
         "Oboom":[
            [
               "1",
               "redirect",
               "none",
               "https:\/\/www.oboom.com\/HPLSZNRY\/",
               "502",
               "download",
               "18"
            ]
         ]
      }
   }
}

这适用于“ 0”

$ddlme_jason['134819'][0]

= WEBRip LD x264 PsO

但是我想在“链接”下显示块。名称和网址。

      "links":{
         "Streamcloud":[
            [
               "1",
               "mediabox",
               "streamcloud.ico",
               "http:\/\/streamcloud.eu\/zaxljnwu4yti\/tn-855.mkv.html",
               "81",
               "stream",
               "0"
            ]
         ],
         "Openload":[
            [
               "1",
               "redirect",
               "none",
               "https:\/\/openload.co\/f\/r9WrAB2RPdI\/tn-603.mkv",
               "123",
               "download",
               "0"
            ]
         ],
[...more code...]

最终,我想将所有来自“链接”的内容自动输出为foreach循环!?

Site1 + Url Site2 +网址 ... 喜欢:

$site1 = "Streamcloud"
$url = "http:\/\/streamcloud.eu\/zaxljnwu4yti\/tn-855.mkv.html"

我不太了解JSON。我会很高兴得到一个答案和一个例子,并在此先感谢您。

1 个答案:

答案 0 :(得分:0)

工作代码:

$json = '{"134819":{"0":"WEBRip LD x264 PsO","1":"1","3":"134819","r":{"t":[13,11],"b":[14,11]},"2":"WEBRip LD x264 PsO","links":{"Streamcloud":[["1","mediabox","streamcloud.ico","http:\/\/streamcloud.eu\/zaxljnwu4yti\/tn-855.mkv.html","81","stream","0"]],"Openload":[["1","redirect","none","https:\/\/openload.co\/f\/r9WrAB2RPdI\/tn-603.mkv","123","download","0"]],"Share-online":[["1","redirect","so.ico","http:\/\/www.share-online.biz\/dl\/9HWBDGHPJ5","67","download","1"]],"Uptobox":[["1","redirect","none","https:\/\/uptobox.com\/4p3yqf8bvzxv","506","download","5"]],"Flashx":[["1","redirect","none","https:\/\/www.flashx.tv\/emx2759pwqef.html","129","stream","8"]],"Oboom":[["1","redirect","none","https:\/\/www.oboom.com\/HPLSZNRY\/","502","download","18"]]}}}'

$arr = json_decode($json);
foreach(reset($arr)->links as $server => $link) {
    echo "{$server}: {$link[0][3]}<br />\n";
}