• php递归操作目录 递归对参数转义


    header("Content-type:text/html;charset=utf-8");
    
    //递归读取目录
    function reddir($path,$level=0) { $dh = opendir($path); while(($row = readdir($dh)) !== false) { if($row == '.' || $row == '..') continue; echo str_repeat('&nbsp',$level*6) . $row . '<br />'; if(is_dir($path . '/' . $row)) reddir($path . '/' . $row , $level+1); } closedir($dh); } reddir($path);
    //递归删除目录
    function deldir($path,$level=0)
    {
        //不是目录,直接返回
        if(!is_dir($path))
            return NULL;
        $dh = opendir($path);
        while(($row = readdir($dh)) != false)
        {
            if($row == '.' || $row == '..')
                continue;
            //判断是否是普通文件
            if(!is_dir($path . '/' . $row))
                unlink($path . '/' . $row);
            else
                deldir($path . '/' . $row , $level+1);//递归把子目录删除
        }
        closedir($dh);
        rmdir($path);
        return true;
    }
    deldir($path);
    //递归对参数进行转义
    function _als($param)
    {
        $arr = array();
        if(is_array($param))
        {
            foreach($param as $k=>$v)
            {
                if(is_array($v))
                    $arr[$k] = _als($v);
                else
                    $arr[$k] = addslashes($v);
            }
            return $arr;
        }
        else
            return addslashes($param);
    }
    
    $arr = array('a' => "'a'",array('a' => "'a'",'b'=>array('a' => "'a'",array('a' => "'a'",'b'=>array('a' => "'a'",array('a' => "'a'",'b'=>array('a' => "'a'",'b'=>array('a' => "'a'"))))))));
    $arr = _als($arr);
    print_r($arr);
  • 相关阅读:
    关于v$librarycache的几个字段含义
    nmon监控
    ORA-01841: (full) year must be between -4713 and +9999,
    MySql 5.7 新特性概览
    权限传递
    ORA-03135 防火墙超时设置断开db link 连接
    Oracle Profile使用详解(转)
    查看Oracle数据库SQL执行历史
    ALTER SEQUENCE 导致 REPLICAT 延时
    trace/trace2命令
  • 原文地址:https://www.cnblogs.com/chenqionghe/p/4230900.html
Copyright © 2020-2023  润新知