[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;
}
[php]PHP_函数收集的更多相关文章
- Javascript常用方法函数收集(二)
Javascript常用方法函数收集(二) 31.判断是否Touch屏幕 function isTouchScreen(){ return (('ontouchstart' in window) || ...
- js函数收集
常见js函数收集: 转自:http://www.qdfuns.com/notes/36030/2eb2d45cccd4e62020b0a6f0586390af.html //运动框架 function ...
- day09-Python运维开发基础(函数收集参数、命名关键字参数与返回值、函数名的特殊使用及 全局/局部变量详解)
1. 函数收集参数.命名关键字参数与返回值.函数名的特殊使用 # ### 默认形参 和 关键字实参 # 默认形参和 关键字实参 在写法上是一样 # 函数的定义处 """默 ...
- javascript常用方法函数收集
收集了一些比较常用的javascript函数. 1.字符串长度截取 function cutstr(str, len) { var temp, icount = 0, patrn = /[^\x00- ...
- python函数收集不确定数量的值
python写函数的时候,有时候会不确定到底传入多少值. 首先是,*args,单星号参数收集参数: 1 #!usr/bin/python 2 #-*-coding:utf-8-*- 3 4 #定义一个 ...
- 实用js函数收集
1. 全选复选框: //复选框全选函数 function SelectAll() { var checkAll = document.getElementsByName("checkAll& ...
- js常用函数收集
在js中,可以使用typeof获取变量或函数的类型,如下: <head runat="server"> <title></title> < ...
- Python3基础 函数 收集参数+普通参数 的示例
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- iOS 中基础字符判断函数收集(如判断大小写、数字等)
函数:isdigit 用法:#include 功能:判断字符c是否为数字 说明:当c为数字0-9时,返回非零值,否则返回零. 函数:islower 用法:#include 功能:判断字符c是否为小写英 ...
随机推荐
- eclipse自动添加javadoc注释
参考文档: https://jingyan.baidu.com/article/36d6ed1f70ea9c1bce488350.html https://www.cnblogs.com/yangji ...
- ASCII码表以及不同进制间的O(1)转换
ASCII码表以及不同进制间的O(1)转换 一.ASCII码表 ASCII全称为American Standard Code for Information Interchange, ...
- MySQL中的联结表
使用联结能够实现用一条SELECT语句检索出存储在多个表中的数据.联结是一种机制,用来在一条SELECT语句中关联表,不是物理实体,其在实际的数据库表中并不存在,DBMS会根据需要建立联结,且会在查询 ...
- 企业官网原型制作分享-Starbucks
星巴克是全球著名的咖啡连锁店,星巴克的产品不单是咖啡,咖啡只是一种载体.而正是通过咖啡这种载体,星巴克把一种独特的格调传送给顾客.咖啡的消费很大程度上是一种感性的文化层次上的消费,文化的沟通需要的就是 ...
- 搭建java环境和java学习
https://blog.csdn.net/fishe_r/article/details/18863447 其中的 java配置文件用: { "shell_cmd": " ...
- .net从网络接口地址获取json,然后解析成对象(二)
整理代码,这是第二种方法来读取json,然后反序列化成对象的,代码如下: public static Order GetOrderInfo(string _tid, string _orderNo) ...
- 使用policheck 检测
Policheck is a profing and testing tool for sensitive terminology and helps in ensuring thattrustwor ...
- java中排序函数sort()使用,Arrays.sort()和Collections.sort()
Java中常用的数组或集合排序的方法有两个,一个是java.util.Arrays中的静态方法Arrays.sort(),还有一个是java.util.Collections中的静态方法的Collec ...
- 选数(NOIP2002)
题目链接:选数 这一题水过去就行了,我们这里用next_permutation去生成各种排列,有一个注意点,我会在代码中标注. #include<bits/stdc++.h> using ...
- spoj 7258 SUBLEX(求第k大字串
其实对sam的拓扑排序我似懂非懂但是会用一点了. /** @xigua */ #include <stdio.h> #include <cmath> #include < ...