//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. Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted

    在java中写switch代码时,参数用的是string,jdk用的是1.8,但是还是报错,说不支持1.7版本以下的,然后查找了项目中的一些文件,打开一个文件如下,发现是1.6的版本,好奇怪啊,按照e ...

  2. Yii2-设置和获取、删除Cookies空值分析(有代码)

    Yii2-设置和获取,删除Cookies空值或值没有变化 原因: 1.不要使用相同的request url, 否则需要刷新才能获取值 可在不同的动作中设置和调用 2.不要在函数中使用exit来中止脚本 ...

  3. 看懂 Fiddler 的瀑布图

    最近准备给组内的新同学们分享下 Fiddler 这枚神器,可以讲的地方太多,我打算把一节课讲不完的内容写在博客上,大家可以随便看看.今天先介绍下 Fiddler 的瀑布图. 每个网络请求都会经历域名解 ...

  4. \\Device\\PhysicalMemory

    从Windows Server 2003 with SP1 以后就禁用了用户态访问\\Device\\PhysicalMemory,要访读取SMBIOS的信息,请使用以下API:•EnumSystem ...

  5. TP QQ 微信 微博登录

    use Org\Util\QQconnect; use Org\Util\Wechatauth; use Org\Util\SaeTOAuthV2; use Org\Util\SaeTClientV2 ...

  6. SQL Server 查询中文字段返回为空

    昨晚维护系统数据时,遇到个奇怪现象.明明数据库里有数据,查询结果就是返回为空.具体情况是这样的,查询工作日志表里关于工作描述的情况,以中文内容匹配工作描述字段,其中匹配内容里包含有空格. 尝试去掉第一 ...

  7. 利用PHPExcel读取excel文件

    $filePath = "7788.xls"; $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel ...

  8. User_Agent大全

    'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Ver ...

  9. Linux/Python学习路线

    Linux: 初级阶段: 熟练掌握常用80个命令: 掌握Linux常用软件包的安装方法,如源码安装,rpm安装等: 学习安装设备驱动程序(如网卡,显卡驱动): 了解Grub/Lilo引导程序以及简单的 ...

  10. python之常用模块篇5

    一.日志模块,logging模块 1)logging模块简单使用,屏幕输出.默认级别30 import logging logging.debug( logging.info( logging.war ...