Home > Article > Backend Development > php里面如何把数组里面的二维数组转化成obj类型的呢
php里面怎么把数组里面的二维数组转化成obj类型的呢?
想把useridinfo这个数组转化成obj类型的怎么做呢?
试了下new ArrayObject($arr[$key])结果把整个都转化了,求大神帮忙。
------解决思路----------------------
$a = array(<br /> array(<br /> 'userIdInfo' => array( 'uid' => '100000113', 'type' => 'ZXIN_IDTYPE::IDNA' ),<br /> 'chgCreditValue' => 50<br /> ),<br /> array(<br /> 'userIdInfo' => array( 'uid' => '10000110', 'type' => 'ZXIN_IDTYPE::IDNA' ),<br /> 'chgCreditValue' => 150<br /> ),<br />);<br />foreach($a as &$v) settype($v, 'object');<br />print_r($a);
Array<br />(<br /> [0] => stdClass Object<br /> (<br /> [userIdInfo] => Array<br /> (<br /> [uid] => 100000113<br /> [type] => ZXIN_IDTYPE::IDNA<br /> )<br /><br /> [chgCreditValue] => 50<br /> )<br /><br /> [1] => stdClass Object<br /> (<br /> [userIdInfo] => Array<br /> (<br /> [uid] => 10000110<br /> [type] => ZXIN_IDTYPE::IDNA<br /> )<br /><br /> [chgCreditValue] => 150<br /> )<br /><br />)<br /><br />