php里面怎么把数组里面的二维数组转化成obj类型的呢?
程序员文章站
2022-03-07 17:31:36
...
想把useridinfo这个数组转化成obj类型的怎么做呢?
试了下new ArrayObject($arr[$key])结果把整个都转化了,求大神帮忙。
试了下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);
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 ))
谢谢版主大人,已经解决了。