反转义var_dump

适用于 array
相关讨论

$str = <<<str
array(1) {
  [0] => array(25) {
    ["catid"] => int(1)
    ["type"] => int(0)
    ["modelid"] => int(0)
    ["domain"] => NULL
    ["parentid"] => int(0)
    ["arrparentid"] => string(1) "0"
    ["child"] => int(0)
    ["arrchildid"] => string(30) "2,3,4,5,6,7,8,9,10,11,12,13,14"
    ["catname"] => string(6) "母婴"
    ["image"] => string(41) "/static/admin/common/images/signIn_14.jpg"
    ["description"] => string(0) ""
    ["parentdir"] => string(0) ""
    ["catdir"] => string(0) ""
    ["url"] => string(0) ""
    ["hits"] => int(0)
    ["setting"] => string(0) ""
    ["listorder"] => int(0)
    ["ismenu"] => int(1)
    ["ishtml"] => int(0)
    ["letter"] => string(0) ""
    ["updatetime"] => int(1551772596)
    ["usable_type"] => string(0) ""
    ["items"] => int(0)
    ["isrecommend"] => int(0)
    ["image2"] => NULL
  }
}
str;
# 处理
$out = preg_replace_callback('/"[^"]*"|[^"]+/','repl',$str);
$up = eval('return '.$out.';');

function repl($m)
{
    return $m[0][0]=='"'?
        str_replace('"',"'",$m[0])
    :
        str_replace("(,","(",
            preg_replace("/(int\((\d+)\)|\s*|(string|)\(\d+\))/","\\2",
                strtr($m[0],"{}[]","(), ")
            )
        );
}
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页