我在php编程方面非常新,我尝试在google上搜索此stackoverflow以获得此解决方案,但仍然没有得到它
我使用以下代码;
$url = 'http://best1st.info/Moviedb/json.php?m=tt2015381&o=json';
$newdata = json_decode(file_get_contents($alsoKnownAs));
$alsoKnownAs = $data['ALSO_KNOWN_AS'];
echo "<pre>";
$newdata = json_decode(file_get_contents($alsoKnownAs));
echo "<pre>";
print_r($newdata);
我尝试从IMDB数据中操作Array,如果数组输出如下:
. and so on
.
.
[TOP_250] => 52
[OSCARS] =>
[AWARDS] =>
[NOMINATIONS] =>
[VOTES] => 166,773
[LANGUAGE] => Array
(
[0] => English
)
[COUNTRY] => Array
(
[0] => USA
[1] => UK
)
[STORYLINE] => On planet Earth in 1988, young Peter Quill ( ) sits in the waiting room of a hospital...
[ALSO_KNOWN_AS] => Array
(
[0] => Guardianes de la galaxia = Argentina
[1] => Qalaktikanin Mühafizeçileri = Azerbaijan
[2] => Пазителите на Галактиката = Bulgaria (Bulgarian title)
[3] => Guardiões da Galáxia = Brazil
)
[RELEASE_DATES] => Array
(
[0] => USA = 21 July 2014
[1] => UK = 24 July 2014
[2] => Canada = 29 July 2014
[3] => Argentina = 31 July 2014
.
.
. and so on
我如何创建一个只有&#34; ALSO_KNOWN_AS&#34;值?
谢谢你
答案 0 :(得分:1)
简单。由于您需要的数据已保存为数组,您可以使用;
检索它$alsoKnownAs = $newdata->ALSO_KNOWN_AS;
所以你的代码看起来像这样;
$url = 'http://best1st.info/Moviedb/json.php?m=tt2015381&o=json';
$newdata = json_decode(file_get_contents($url));
$alsoKnownAs = $newdata->ALSO_KNOWN_AS;
然后,您可以使用以下内容循环显示值;
foreach($alsoKnownAs as $value) {
echo '<pre>' . $value . '</pre><br>'; // to print each row of the data
// $value is the value of each part of the array in turn, starting from 0
}