Home > Backend Development > PHP Tutorial > php里面怎么把数组里面的二维数组转化成obj类型的呢?

php里面怎么把数组里面的二维数组转化成obj类型的呢?

WBOY
Release: 2016-06-20 12:46:10
Original
1255 people have browsed it


想把useridinfo这个数组转化成obj类型的怎么做呢?
试了下new ArrayObject($arr[$key])结果把整个都转化了,求大神帮忙。


回复讨论(解决方案)

$a = array(  array(    'userIdInfo' => array( 'uid' => '100000113', 'type' => 'ZXIN_IDTYPE::IDNA' ),    'chgCreditValue' => 50  ),  array(    'userIdInfo' => array( 'uid' => '10000110', 'type' => 'ZXIN_IDTYPE::IDNA' ),    'chgCreditValue' => 150  ),);foreach($a as &$v)  settype($v, 'object');print_r($a);
Copy after login
Array(    [0] => stdClass Object        (            [userIdInfo] => Array                (                    [uid] => 100000113                    [type] => ZXIN_IDTYPE::IDNA                )            [chgCreditValue] => 50        )    [1] => stdClass Object        (            [userIdInfo] => Array                (                    [uid] => 10000110                    [type] => ZXIN_IDTYPE::IDNA                )            [chgCreditValue] => 150        ))
Copy after login

谢谢版主大人,已经解决了。

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