• [php]PHP_函数收集


    //http://php.net/manual/en/control-structures.break.php

    //break ends execution of the current for, foreach, while, do-while or switch structure.

    //break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of. The default value is 1, only the immediate enclosing structure is broken out of.

    //  
    // Function1 : 生成随机字符串 private function _generateCode($ref_list) { do{ $str_num = str_replace(array("o" , "i" , "l" , "z" , "0" , "1" , "2") , "" , md5(strtotime('now'))); $str_num = substr($str_num , 0 , 4); }while(isset($ref_list[$str_num])); return $str_num; }

    // Function2 : 对数组中的数据排序(usort($arr_questionInfo , array($this , 'cmp'));)
       private function cmp($a , $b)
        {
            $aLevel = ceil($a['match_rate']  * 100);
            $bLevel = ceil($b['match_rate']  * 100);
            
            if($aLevel == $bLevel)
            {
                if($a['score'] == $b['score'])
                {
                    return 0;
                } else if($a['score'] > $b['score']) {
                    return -1;
                } else {
                    return 1;
                }
            } else if ($aLevel > $bLevel)
            {
                return -1;
            } else {
                return 1;
            }
        }
    
    // Function 3: 两个数组的比较
        private function _formatIndex($arr_tableIndex , $str_index)
        {
    		$arr_unformatedIndex = explode(INDEX_COMBINE_SEPERATE , $str_index);
    		$str_formatedIndex = false;
    		foreach($arr_tableIndex as $value)
    		{
    		  $arr_tableIndex = explode(INDEX_COMBINE_SEPERATE , $value);
    		  //找到对应的索引的名了,直接退出
    		  if(empty(array_diff($arr_unformatedIndex , $arr_tableIndex)) && 
    					empty(array_diff($arr_tableIndex , $arr_unformatedIndex)))
    		  {
    			$str_formatedIndex = $value;
    			break;
    		  }
    		}
    		return $str_formatedIndex;
        }   
     // Funtion 4 : 通过引用直接在遍历数组的过程中改变数组的值
    
      public static function formatValue(&$arr_value)
      { foreach($arr_value as &$value) { if(is_array($value))     { $value = implode("," , $value);     } }   }
    /*
    		 * @desc 生成远程的唯一ID。ID一共8个字节,
    		 *	 1字节:用于类型前缀
    			 5字节: 用于时间
    			 3字节: 用于自增
    		 * @param
    		 *		$redisLink redis连接
    		 *		$type ID的类型
    		 *		$key 主键值
    		 */
    		static function createRemotID($redisLink , $type , $key)
    		{
    			$idPrefix = $type << 56;
    			$maxNum = 2 << 20;
    			do{
    				$idNum = $redisLink->incr($key);				
    				if($idNum >= $maxNum)
    				{
    					$redisLink->set($key , 0);
    				}
    			} while($idNum >= $maxNum);
    			
    			$time = ceil(microtime(true) * 1000) << 24;
    			$id = $idPrefix + $time + $idNum;
    			$id .= "";
    			return $id;
    		}
    
  • 相关阅读:
    关于《注意力模型--Attention注意力机制》的学习
    神经网络参数计算
    FPN(feature pyramid networks)算法讲解
    RetinaNet-focal loss
    论文阅读: RetinaNet
    CNN+LSTM:看图说话
    非极大值抑制-NMS
    python IO文件操作 file文件操作
    软件测试定义 分类
    软件生命周期
  • 原文地址:https://www.cnblogs.com/shuman/p/5102773.html
Copyright © 2020-2023  润新知