[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是否为小写英 ...
随机推荐
- 原生和web交互jsbridge交互总结
技术点:jsbridge. 一: 参数及其意义(代码意义结合支付项目) 二:主动请求原生参数与方法(sendapi) 参数1 判断接口类型 参数2 传递给原生的数据 参数3 回调函数,response ...
- Java开发环境安装配置
电脑配置:Win7 64位 JDK1.8+Apache Tomcat8.5.4 下载JDK1.8 全名: Java SE Development Kit 8u151,下载最新稳定版本 下载地址:htt ...
- IOS语法
2017-07-15 NSDictionary里要用到的类型转换 [NSNumber numberWithInt: 89] 2017-12-10 定义一个Block的写法 typedef void ...
- 使用mysql proxy对数据库进行读写分离
服务器安排如下: 192.168.100.128 主 192.168.100.129 从 192.168.100.130 mysql-proxy 1.在100.130中下载安装mysql-proxy ...
- 解决mysql安装出现error Nr.1045问题
我们在windows下安装mysql最后一步时会出现Access denied for user 'root'@localhost'(using password:No)的问题.这几个问题经常出现在卸 ...
- Scrapy的安装和基本使用方法
Scrapy的安装 1. Windows下安装流程: 方法一: 命令行执行pip install scrapy 安装scrapy 注意:如果有anaconda,也可以打开“Anaconda promp ...
- create a plugin for PowerShell ISE
可参考:Creating Add-ons, Plugins, and Tools for the PowerShell ISE http://www.leeholmes.com/blog/2013/0 ...
- 棋盘问题(NOIP1997)
题目链接:棋盘问题 这道题水不水呢?还是很水的,为什么?因为数据太小了.直接算就行了. #include<bits/stdc++.h> using namespace std; int m ...
- CollisionFlags
CollisionFlags是CharactorController的返回值,表示碰撞的信息 Values: None Sides Above Below function Update () { v ...
- MZOJ 1345 hero
一道宽搜模版题,可写错了两个地方的我只得了56(掩面痛哭) http://10.37.2.111/problem.php?id=1345 先看看正确的 #include <bits/stdc++ ...