drlnwji79147769 2011-07-25 16:03
浏览 128
已采纳

有没有一种简单的方法来获取print_r或var_dump的输出并将其转换为数组?

I want to take the output of a var_dump or print_r and convert it to an array that mirrors what was in the original.

convert this:

stdClass Object
(
    [title] => Edison's Friends
    [status] => 1

    [field_deck_owner] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [uid] => 15
                        )

                )

        )

    [name] => Mack
)

to this:

$array =  array(
    'title' -> 'Edison's Friends',
    'status' -> '1',
    'field_deck_owner' = array (
        array(
            array (
                'uid'->15
                )
            )
        ),
    'name' = "Mack"

);

Are there scripts that do this? A javascript site ;-) Something?

  • 写回答

7条回答 默认 最新

  • doudundian9558 2011-07-25 16:09
    关注

    Not a parser like you're asking for, but if you just want an array of the object's properties you can just cast it to an array directly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题