如何在PHP中访问多维关联JS数组值?

如何在PHP中访问多维关联JS数组值?,php,multidimensional-array,Php,Multidimensional Array,这是我在PHP中收到的多维关联javascript数组: array (size=2) 0 => object(stdClass)[1] public 'count' => string '30' (length=2) public 'size' => string '1' (length=0) public 'name' => string 'aa' (length=0) public 'pid' =>

这是我在PHP中收到的多维关联javascript数组:

array (size=2)
 0 => 
    object(stdClass)[1]
      public 'count' => string '30' (length=2)
      public 'size' => string '1' (length=0)
      public 'name' => string 'aa' (length=0)
      public 'pid' => string '910' (length=0)
      public 'price' => string '300' (length=0)
  1 => 
    object(stdClass)[2]
      public 'count' => string '30' (length=2)
      public 'size' => string '2' (length=0)
      public 'name' => string 'bb' (length=0)
      public 'pid' => string '920' (length=0)
      public 'price' => string '400' (length=0)

如何在PHP中访问多维关联JS数组值?

例如,您必须将其用作对象

foreach($array as $obj) echo $obj->count;

问题得到了回答,但我有一个额外的评论-我假设您在代码中使用了
json\u decode()
,并得到了上述结果?如果是这样,那么值得注意的是,
json\u decode()
默认情况下为JS对象文本创建
stdClass
对象实例。但是,您可以通过将
true
作为第二个参数传递给
$assoc
参数来强制PHP关联数组;e、 g:
json\u解码($json,true)。此处示例:-有关
json\u decode
的更多信息此处:如何分别访问
对象(stdClass)[1]
对象(stdClass)[2]
值?@Unique
$array[0]->property
$array[1]->property