从数组中删除嵌套数组并在php中分配新变量

时间:2014-06-13 11:16:49

标签: php arrays json

好的,所以我读到了多维数组但我的问题是这样的,我将JSON字符串反序列化为php数组,并且在解码时输出就是这样。现在我想将comparisionResultDTOarr分配给一个新数组。数组的名称是$ data

array (size=1)
  0 => 
    object(stdClass)[1]
      public 'class' => string 'com.ofss.fc.app.ops.config.response.CompareDomainObjectResponse' (length=63)
      public 'comparisonResultDTOarr' => 
        array (size=24)
          0 => 
            object(stdClass)[2]
              ...
          1 => 
            object(stdClass)[5]
              ...
          2 => 
            object(stdClass)[8]
              ...
          3 => 
            object(stdClass)[11]
              ...
          4 => 
            object(stdClass)[14]
              ...
          5 => 
            object(stdClass)[17]
              ...
          6 => 
            object(stdClass)[20]
              ...
          7 => 
            object(stdClass)[23]
              ...
          8 => 
            object(stdClass)[26]
              ...
          9 => 
            object(stdClass)[29]
              ...
          10 => 
            object(stdClass)[32]
              ...
          11 => 
            object(stdClass)[35]
              ...
          12 => 
            object(stdClass)[38]
              ...
          13 => 
            object(stdClass)[41]
              ...
          14 => 
            object(stdClass)[44]
              ...
          15 => 
            object(stdClass)[47]
              ...
          16 => 
            object(stdClass)[50]
              ...
          17 => 
            object(stdClass)[53]
              ...
          18 => 
            object(stdClass)[56]
              ...
          19 => 
            object(stdClass)[59]
              ...
          20 => 
            object(stdClass)[62]
              ...
          21 => 
            object(stdClass)[65]
              ...
          22 => 
            object(stdClass)[68]
              ...
          23 => 
            object(stdClass)[71]
              ...
      public 'configVersionId' => null
      public 'maintenanceType' => null
      public 'percentage' => float 93.103448275862
      public 'resultColor' => string 'GREEN' (length=5)
      public 'status' => null

我尝试过: -

$new_array = $data[0]->['comparisionResultDTOarr'];

但这似乎不起作用。任何人都可以帮助我吗?

0 个答案:

没有答案