如何在PHP中获取数组内容

如何在PHP中获取数组内容,php,arrays,Php,Arrays,我试图在PHP中回显响应(数组),但它没有返回所需的值 这是我的密码 <?php $id = $_GET['id']; $array = file_get_contents('http://wen.com/api.php?id='.$id); echo $array[0]; // it returns A, while I need Friday here echo $array[1]; // it returns r, while I need Tuesday, 17 November

我试图在PHP中回显响应(数组),但它没有返回所需的值

这是我的密码

<?php
$id = $_GET['id'];
$array = file_get_contents('http://wen.com/api.php?id='.$id);
echo $array[0]; // it returns A, while I need Friday here
echo $array[1]; // it returns r, while I need Tuesday, 17 November here


?>
编辑:

我在文件\u get\u内容中使用的api代码是:

$html =  file_get_contents("$url");



 $dom = new DomDocument();
            $dom->loadHTML($html);
            $dom_xpath = new DOMXpath($dom);
            $elements = $dom_xpath->query('//span[@class="nowrap"]');
            foreach($elements as $data){
               $array[] = $data->nodeValue;
            }

print_r($array);

已解决:
我刚刚替换了print\u r($array);通过echo json_编码($array)

看起来好像
file\u get\u contents
正在返回一个值为
Array([0]=>Frid..
的字符串。这个文件是如何生成的,在类似JSON的东西中可能更好。似乎在APIreplace
print\r($Array);
by
echo JSON\u encode($Array)
$html =  file_get_contents("$url");



 $dom = new DomDocument();
            $dom->loadHTML($html);
            $dom_xpath = new DOMXpath($dom);
            $elements = $dom_xpath->query('//span[@class="nowrap"]');
            foreach($elements as $data){
               $array[] = $data->nodeValue;
            }

print_r($array);