stdClass数组? [英] stdClass to array?

查看:72
本文介绍了stdClass数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

stdClass Object
(
    [0] => stdClass Object
        (
            [one] => aaa
            [two] => sss
        )

    [1] => stdClass Object
        (
            [one] => ddd
            [two] => fff
        )

    [2] => stdClass Object
        (
            [one] => ggg
            [two] => hhh
        )
}

并且我必须使用密钥来获取它,例如:

and i must get this with keys, for example:

$var = $stdClass[0]; 

但是我有错误:

致命错误:无法将类型为stdClass的对象用作数组中的

Fatal error: Cannot use object of type stdClass as array in

是否可以将这个stdClass解析为数组并将其与键一起使用?

Is possible parse this stdClass to array and use this with keys?

推荐答案

将其投射到数组中:

$array = (array)$stdClass;

这篇关于stdClass数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆