数组数据编码格式转换

来源:互联网 发布:hashmap的hash算法 编辑:程序博客网 时间:2024/05/20 01:11
//编码格式转换
function format_C($gg,$uu,$arr){
    format_change($gg, $uu,$arr,true);
    return $arr;
}
function format_change($gg,$uu,&$arr,$apply_to_keys = false){
    static $aa_counter=0;
    if(++$aa_counter>6){
        die('possible deep attack');
    }
    foreach($arr as $key=>$value){
        if(is_array($value)){
            format_change($gg,$uu,$arr[$key],true);
        }else{
            $arr[$key] = iconv($gg,$uu,$value);
        }
        if($apply_to_keys && is_string($key)){
            $new_key = iconv($gg,$uu,$key);
            if($new_key!=$key){
                $arr[$new_key] = $arr[$key];
                unset($arr[$key]);
            }
        }
    }
    $aa_counter--;
}
0 0
原创粉丝点击