有没有一种方法来分析print_r的输出 [英] Is there a way to parse the output of 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_rDuplicate 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.phpHowever
var_export()
can be an alternative if your logs are generated usingvar_export()
. This way, you only needeval()
to retrieve the exported array.这篇关于有没有一种方法来分析print_r的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!