有没有一种方法来分析print_r的输出 [英] Is there a way to parse the output of print_r

查看:432
本文介绍了有没有一种方法来分析print_r的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

可能重复:结果
  创建阵列打印的print_r


印着的print_r 创建阵列的复制
其中也有一个不错的code为例来解决这个问题。

我需要扭转其具有作为输出的print_r($数据,真正的)错误日志。结果
例如数据将如下所示:

 阵列

    [主题] =>这是主题
    [正文] => &所述p为H.;亲爱的用户,与所述; / P>&所述; P>这是电子邮件&所述的主体; / P>
    [from_id] => 0
    [FROM_EMAIL] => admin@karakas.org
    [转] =>排列
        (
            [0] =>排列
                (
                    [ID] => 0
                    [邮件] => 64909
                )        )    [send_to_inbox] => 1


在PHP手册中有一个在注释 print_r_reverse()函数:
http://php.net/manual/en/function.print-r.php

var_export()可如果你的日志使用会生成一个另外的 var_export()。通过这种方式,你只需要的eval()来检索导出的阵列。

Possible Duplicate:
Create array printed with print_r

Duplicate of Create array printed with print_r which also has a nice code example to solve this

I need to reverse an error log which has as output print_r($data,true).
Example data would look like:

Array
(
    [subject] => this is the subject
    [body] => <p>Dear user,</p><p>this is the body of the email</p>
    [from_id] => 0
    [from_email] => admin@karakas.org
    [to] => Array
        (
            [0] => Array
                (
                    [id] => 0
                    [email] => 64909
                )

        )

    [send_to_inbox] => 1
)

解决方案

In the PHP manual there's a print_r_reverse() function in comments : http://php.net/manual/en/function.print-r.php

However var_export() can be an alternative if your logs are generated using var_export(). This way, you only need eval() to retrieve the exported array.

这篇关于有没有一种方法来分析print_r的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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