怎么取出old里面对应的值和new对应的值,php二维数组问题

WBOY
Release: 2016-06-06 20:44:01
Original
998 people have browsed it

怎么取出old里面对应的值和new对应的值,php二维数组问题

回复内容:

怎么取出old里面对应的值和new对应的值,php二维数组问题

这是json_decode出来的stdClass Object么?如果是的话,那你应该设定第二个参数:json_decode($data,true),这样就是一个数组了。

如果不是的话,你应该用(array)强转
这里有份递归转的

<code class="lang-php">function object_array($array){
  if(is_object($array)){
    $array = (array)$array;
  }
  if(is_array($array)){
    foreach($array as $key=>$value){
      $array[$key] = object_array($value);
    }
  }
  return $array;
} 

$array = object_array($data);
</code>
Copy after login

眼睛看哪里去了,dump都说的清清楚楚是Object了怎么还是二维数组问题,囧死。
试试 $a->old$a->new 吧。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!