Php 如何从数组中获取值?

Php 如何从数组中获取值?,php,arrays,Php,Arrays,假设我有这样一个数组: Array ( [0] => stdClass Object ( [nid] => 2340 [node_created] => 1390349535 ) [1] => stdClass Object ( [nid] => 1176 [node_created] => 1390

假设我有这样一个数组:

Array
(
    [0] => stdClass Object
        (
            [nid] => 2340
            [node_created] => 1390349535
        )

    [1] => stdClass Object
        (
            [nid] => 1176
            [node_created] => 1390086303
        )

    [2] => stdClass Object
        (
            [nid] => 1133
            [node_created] => 1390086313
        )

)
如何获取第[1]部分中[nid]之后的值

$value = $array[1];
echo $value->nid;

我相信这会抓住你想要的价值。

我假设你正在做以下事情:

<?php

$o = (object)array("nid"=>123);
// Adding $o three times to the array to illustrate the idea.
$myArray = array($o, $o, $o);
echo $myArray[1]->nid;

?>


您正在使用匿名对象实例。在这种情况下,您可以通过使用
->

$myArray[1]->nid
像访问任何其他对象一样访问该值。。。。请尝试阅读PHP手册:和may中标题为
使用方括号语法访问数组元素的部分help@Wrikken没错,fixing@MarkBaker:谢谢你的链接!我是php新手,找不到答案。