Home  >  Article  >  php教程  >  一段没什么意思的代码

一段没什么意思的代码

PHP中文网
PHP中文网Original
2016-05-25 17:07:101184browse

一段没什么意思的代码

   /*
    *  測試参数完整,并格式化数组参数 
    *  返回 FALSE, array

   public function  format_array_value($a_params = null, $a_rule = null)
   {
        if( is_array($a_params) && !empty($a_params) && is_array($a_rule) && !empty($a_rule) )
        { 
              
              foreach ($a_rule as $key => $value)
              {
                  if(array_key_exists($key, $a_params))
                  {
                  	if($value == 'int' or $value == 'integer')
                  		  $a_params[$key] = intval($a_params[$key]);
                  	elseif ($value == 'string') {
                  		  $a_params[$key] = strval($a_params[$key]);
                  	}elseif ($value == 'double' or $value == 'float') {
                  		  $a_params[$key] = doubleval($a_params[$key]);
                  	}elseif ($value == "boolean") {
                  		  $a_params[$key] = $a_params[$key] ? true : false;
                  	}elseif (preg_match("/^[%bcdeufFosxX]$/",$value)){
                  		    // 生成字符字
  			 $a_params[$key] = sprintf("%".$value,$a_params[$key]);
                  	}else{
                        return FALSE;
                    }
                  }else{
                  	return 	FALSE;
                  }
              }

             return $a_params;  

        }
        else
        {
            return FALSE;
        }
   }  //end check_array_value func

                   

以上就是一段没什么意思的代码的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn