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

//break ends execution of the current forforeachwhiledo-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_函数收集的更多相关文章

  1. Javascript常用方法函数收集(二)

    Javascript常用方法函数收集(二) 31.判断是否Touch屏幕 function isTouchScreen(){ return (('ontouchstart' in window) || ...

  2. js函数收集

    常见js函数收集: 转自:http://www.qdfuns.com/notes/36030/2eb2d45cccd4e62020b0a6f0586390af.html //运动框架 function ...

  3. day09-Python运维开发基础(函数收集参数、命名关键字参数与返回值、函数名的特殊使用及 全局/局部变量详解)

    1. 函数收集参数.命名关键字参数与返回值.函数名的特殊使用 # ### 默认形参 和 关键字实参 # 默认形参和 关键字实参 在写法上是一样 # 函数的定义处 """默 ...

  4. javascript常用方法函数收集

    收集了一些比较常用的javascript函数. 1.字符串长度截取 function cutstr(str, len) { var temp, icount = 0, patrn = /[^\x00- ...

  5. python函数收集不确定数量的值

    python写函数的时候,有时候会不确定到底传入多少值. 首先是,*args,单星号参数收集参数: 1 #!usr/bin/python 2 #-*-coding:utf-8-*- 3 4 #定义一个 ...

  6. 实用js函数收集

    1. 全选复选框: //复选框全选函数 function SelectAll() { var checkAll = document.getElementsByName("checkAll& ...

  7. js常用函数收集

    在js中,可以使用typeof获取变量或函数的类型,如下: <head runat="server"> <title></title> < ...

  8. Python3基础 函数 收集参数+普通参数 的示例

    镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...

  9. iOS 中基础字符判断函数收集(如判断大小写、数字等)

    函数:isdigit 用法:#include 功能:判断字符c是否为数字 说明:当c为数字0-9时,返回非零值,否则返回零. 函数:islower 用法:#include 功能:判断字符c是否为小写英 ...

随机推荐

  1. 不解压查看tar.gz包内文件

    通过tar命令备份.解压缩文件,也可在不解压缩文件时查看包内的文件信息. 使用如下参数: tar -ztvf file.tar.gz 将列出所有包内的文件列表,包括目录 -z, --gzip, --g ...

  2. 对象回收过程?线程池执行过程? map原理?集合类关系?synchronized 和 volatile ? 同一个类的方法事务传播控制还有作用吗?java 锁

    1.  对象回收过程? 可达性分析算法: 如果一个对象从 GC Roots 不可达时,则证明此对象不可用. 通过一系列称为GC ROOTS的对象作为起点,从这些起点往下搜索,搜索走过的路径 称为引用链 ...

  3. linux 和 主机通信的另类方法

    偶然发现,linux可以从github上直接下载代码.这样就能用windows写好代码,直接给linux来跑了.很方便. 当然是因为我还不会配置网络来让linux和windows通信.弄了一个下午也没 ...

  4. g2o相关问题cs.h,以及no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)

    1.对于cs.h找不到的情况 1)编译的时候一定要把csparse在EXTERNAL文件中,编译进去. 2)修改CMakeLists.txt文件中的include_directories中的${CPA ...

  5. 关于部署传统的Dynamic Web项目

    现在大部分都是采用maven构建的项目,但是偶尔也会遇到一些较老的项目,采用的是传统的动态Web项目. 我最近碰到这样一个项目,项目用的jar包都放在了WEB-INF/lib目录下.之前的人采用的部署 ...

  6. 在win8 App中,StorageFile比Path更好用

    Skip the path: stick to the StorageFile: http://blogs.msdn.com/b/wsdevsol/archive/2012/12/05/stray-f ...

  7. 【Web】Nginx配置开机启动

    在添加nginx服务之后,大家会希望开机伴随启动nginx,避免手动路径输入启动: nginx官方提供了启动脚本:https://www.nginx.com/resources/wiki/start/ ...

  8. mysql之多表查询和pymysql模块

    一 多表查找方法 1 交叉连接:不使用任何的判断条件,生成笛卡尔积.第一个表的行数乘以第二个表的行数就等于笛卡尔积结果集的行数. mysql> select * from student,cla ...

  9. vue.js实战(文摘)

    ---------------第1篇 基础篇 第1章 初始vue.js 第2章 数据绑定和第一个vue应用 第3章 计算属性 第4章 v-bind及class与style绑定 第5章 内置命令 第6章 ...

  10. java的Scanner获取输入内容

    //导入 scanner的包 import java.util.Scanner; Scanner scanner = new Scanner(System.in); System.out.printl ...