骨子里我们能够动用array_filter函数轻易去掉多维空值,而数组的下标未有变动,上面是比如用法:
‘滔哥’, 1 => false, 2 => 1, 3 => null, 4 => ”, 5 =>
‘//www.jb51.net’, 6 => ‘0’ ); print_r; ?> 上面代码输出结果为:
Array ( [0] => 滔哥 [2] => 1 [5] => //www.jb51.net )
那样就把为空大概null或然false的值杀绝掉,防止程序现身漏洞!

复制代码 代码如下:

后天在翻看手册查询array_filter()的施用细节时,看见了个小关键点:If no
callback is supplied, all entries of input equal to FALSE (see
converting to boolean) will be removed. 若无交到回调函数,全数的卓殊FALSE
的要素将会被移除掉,那不刚好能够用来过滤一些有空成分的数组吗?急迅写个例子测验一下设法:复制代码 代码如下:$entry = array(

var www_jb51_net = function (obj, url, title) {
    var e = window.event || arguments.callee.caller.arguments[0];
    var B = {
        IE : /MSIE/.test(window.navigator.userAgent) && !window.opera
        , FF : /Firefox/.test(window.navigator.userAgent)
        , OP : !!window.opera
    };
    obj.onmousedown = null;
    if (B.IE) {
        obj.attachEvent(“onmouseup”, function () {
            try {
                window.external.AddFavorite(url, title);
                window.event.returnValue = false;
            } catch (exp) {}
        });
    } else {
        if (B.FF || obj.nodeName.toLowerCase() == “a”) {
            obj.setAttribute(“rel”, “sidebar”), obj.title = title,
obj.href = url;
        } else if (B.OP) {
            var a = document.createElement(“a”);
            a.rel = “sidebar”, a.title = title, a.href = url;
            obj.parentNode.insertBefore(a, obj);
            a.appendChild(obj);
            a = null;
        }
    }
};
<a href=”javascript:void(0);return%20false;”
onMouseDown=”www_jb51_net(this, ”,
‘脚本之家是本国正式的网址建设财富、脚本编制程序学习类网址’)”>收藏脚本之家</a>

0 => ‘莲灰东极岛的博客’,

代码如下: var www_jb51_net = function
(obj, url, title) { var e = window.event ||
arguments.callee.caller.arguments[0]; var B = { IE :
/MSIE/.test(window.navigator…

1 => false,

3 => null,

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注