Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.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 如何从API获取数组_Php_Arrays_Api - Fatal编程技术网

Php 如何从API获取数组

Php 如何从API获取数组,php,arrays,api,Php,Arrays,Api,我想从 但是我不知道如何从api中提取数组 有人能帮我吗 我的代码是: $title = 'the+walking+dead'; $title2 = urlencode($title); $json=file_get_contents("http://www.omdbapi.com/?t=$title2&season=6&r=json"); $details=json_decode($json); if($details->Response=='True') {

我想从

但是我不知道如何从api中提取数组

有人能帮我吗

我的代码是:

$title = 'the+walking+dead';
$title2 = urlencode($title);
$json=file_get_contents("http://www.omdbapi.com/?t=$title2&season=6&r=json");
$details=json_decode($json);
if($details->Response=='True')
{   
        $episodios=$details->Episodes;
}
$title='the+walking+dead';
$title2=urlencode($title);
$json=文件\u获取\u内容(“http://www.omdbapi.com/?t=$title2&season=6&r=json“;
$details=json_decode($json);
如果($details->Response==“True”){
回显“有”。计数($details->集)。“集
”; foreach($details->剧集为$key=>$eposion){ echo“事件标准编号为”。($key+1)。”
; 回显“插曲编号:”.$SECTION->插曲。“
”; echo“已发布:”.$插曲->已发布。“
”; } }
$title='the+walking+dead';
$title2=urlencode($title);
$json=文件\u获取\u内容(“http://www.omdbapi.com/?t=$title2&season=6&r=json“;
$details=json_decode($json);
如果($details->Response==“True”){
回显“有”。计数($details->集)。“集
”; foreach($details->剧集为$key=>$eposion){ echo“事件标准编号为”。($key+1)。”
; 回显“插曲编号:”.$SECTION->插曲。“
”; echo“已发布:”.$插曲->已发布。“
”; } }



添加语言标签。添加语言标签。谢谢你,本季的剧集是谁?要获取总数?
if($details->Response=='True'){$i=0;foreach($details->集为$session){$i++;echo'集号:'.$session->集。
';echo'已发布:'.$session->已发布。
;}echo$i;}
只需添加一个计数器变量(例如
$i
),在每一次迭代中,加上1,Matei可能会用full更新答案code@AdolfoRodrigues我刚刚更新了我的答案。。要计算剧集数,只需使用
count()
功能。谢谢你,我是谁?要获取总数?
if($details->Response=='True'){$i=0;foreach($details->集为$session){$i++;echo'集号:'.$session->集。
';echo'已发布:'.$session->已发布。
;}echo$i;}
只需添加一个计数器变量(例如
$i
),在每一次迭代中,加上1,Matei可能会用full更新答案code@AdolfoRodrigues我刚刚更新了我的答案。。要计算剧集数,只需使用
count()
函数
$title = 'the+walking+dead';
$title2 = urlencode($title);
$json = file_get_contents("http://www.omdbapi.com/?t=$title2&season=6&r=json");
$details = json_decode($json);
if ($details->Response == 'True') {

    echo 'There are ' . count($details->Episodes) . ' episodes<br />';

    foreach ($details->Episodes as $key => $episode) {
        echo 'Episode criteria number is ' . ($key + 1) . '<br />';
        echo 'Episode Number: ' . $episode->Episode . '<br />';
        echo 'Released: ' . $episode->Released . '<br />';
    }
}
<?php

$title = 'the+walking+dead';
$title2 = urlencode($title);
$json=file_get_contents("http://www.omdbapi.com/t=$title2&season=6&r=json");
$details=json_decode($json);
if($details->Response=='True')
{   
    $episodios=$details->Episodes;
    foreach ($episodios as $episode) {
        echo 'Episode Number: ' . $episode->Episode . '<br />';
        echo 'Released Date: ' . $episode->Released . '<br />';
    }
}
?>