php 通过array_walk调试数组功能实例

本范例演示了PHP中如何通过array_walk调试数组,输出一个可读性良好的格式,PHP通过array_walk调试数组的方法,感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
经测试代码如下:

/**
 * 通过array_walk调试数组
 *
 * @param 
 * @arrange (编程之家) jb51.cc
 **/
function debug_val($val,$key='',$depth=0) {
 
    if (is_array($val)){
        // call this function again with the sub-array:
        array_walk($val,'debug_val',$depth+5);
    }
    else {
        // if we hit a string or bool,etc. then print it:
        print str_repeat(' ',$depth);          
        print '<span style=color: blue;>' . $key . '</span>: ';
        print var_export($val,true);
        print <br/>\n;
    }
}
 
 
/*example-start*/
 
// setup the test array 
$array = array(
    'PHP','cool',array('foo',1,2,3,array('mixed' => 'bar')),'PHP' => 'array','yes' => true,'no' => false
);
 
// debug the array
debug_val($array);
 
/*example-end*/


/***   代码来自编程之家 jb51.cc(jb51.cc)   ***/

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...