This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function string2ByteArray($string) { | |
| return unpack('C*', $string); | |
| } | |
| function byteArray2String($byteArray) { | |
| $chars = array_map("chr", $byteArray); | |
| return join($chars); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /* | |
| * 经典的概率算法, | |
| * $proArr是一个预先设置的数组, | |
| * 假设数组为:array(100,200,300,400), | |
| * 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内, | |
| * 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间, | |
| * 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。 | |
| * 这样 筛选到最终,总会有一个数满足要求。 | |
| * 就相当于去一个箱子里摸东西, |