Php 将数组打印到变量

Php 将数组打印到变量,php,arrays,variables,Php,Arrays,Variables,我是一个PHP新手,所以这可能很容易,但我就是想不出来。我正在使用一个脚本,它使用there API从电影数据库“TMDB”中提取信息 以下代码: $playing = $tmdb_V3->nowPlayingMovies($page=1); echo"<pre>";print_r($playing);echo"</pre>"; [0] => Array ( [adult] => [ba

我是一个PHP新手,所以这可能很容易,但我就是想不出来。我正在使用一个脚本,它使用there API从电影数据库“TMDB”中提取信息

以下代码:

$playing = $tmdb_V3->nowPlayingMovies($page=1);
echo"<pre>";print_r($playing);echo"</pre>";
[0] => Array
        (
            [adult] => 
            [backdrop_path] => /aBkkrhQS4rO3u1OTahywtSXu3It.jpg
            [id] => 127585
            [original_title] => X-Men: Days of Future Past
            [release_date] => 2014-05-23
            [poster_path] => /qKkFk9HELmABpcPoc1HHZGIxQ5a.jpg
            [popularity] => 232.77188788256
            [title] => X-Men: Days of Future Past
            [vote_average] => 7.2
            [vote_count] => 178
等等

我想做的是提取信息并将其保存为自己的变量。例如:

foreach($playing["results"] as $array){

   $your_variable=$array["id"]; // and so on...
}
将是第一部电影,因此我可以将其[id]保存为
$id
,[original_title]保存为
$title
,依此类推,这样我就可以在页面的任何位置调用这些变量

这可能吗

我基本上希望从数据库中获取所有信息并将其显示在PHP文件中,但不是通过打印数组


非常感谢您提供任何信息。

请访问以下内容:

$playing['results'][0]['title']  // would give you the first movie title
$playing['results'][1]['title']  // would give you the second movie title

您可以按当前的方式使用阵列分别瞄准电影


可以,但阵列的整个概念正在下降。你知道,你可以访问某些数组键吗?@UrbanTanCreams:PHP手册中有很多例子对其进行了很好的描述。您可以在链接的重复问题中找到解释。这里接受的答案也包含了相关章节的PHP手册链接。如果您想将这样一个数组条目作为变量传递到HTML片段中,以下include helper可能会很有用:
$playing['results'][0]['title']  // would give you the first movie title
$playing['results'][1]['title']  // would give you the second movie title