получить значение json_decode с индивидуальным именем - PullRequest
0 голосов
/ 05 ноября 2018

как я могу получить индивидуальную информацию от 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

Но я хочу отобразить блоки под "ссылками". Название и URL.

      "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!?

Сайт1 + URL Сайт2 + URL ... Как:

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

Я пока не очень хорошо знаю JSON. Я был бы очень рад ответу и примеру и заранее благодарю.

1 Ответ

0 голосов
/ 10 ноября 2018

РАБОЧИЙ КОД:

$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";
}
...