PHP查找10G大文本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <?php
ini_set("memory_limit","1024M");
function rand_file($file){ @$hand=fopen($file,"a+"); if($hand){ for($i=1;$i <=999999 ; $i++){ $str=md5(mt_rand())." "; fwrite($hand,$str,100); } fclose($hand); } if(is_file($file)){ echo "ok"; }else{ echo "no"; } }
function seek($arr,$seek="a"){ if(is_array($arr)){ $ar=array(); foreach($arr as $key => $value){ if(strstr($arr[$key],$seek)){ $ar[]=$key; } } return $ar; }else{ return false; } }
function fread_arr($file,$size){ $hand=fopen($file,"r"); if($hand){ $get=array(); while(!feof($hand)){ $get[]=fread($hand,$size); } fclose($hand); return $get; }else{ return false; } }
function fgets_arr($file,$size){ $hand=fopen($file,"r"); if($hand){ $get=array(); while(!feof($hand)){ $get[]=fgets($hand,$size); } fclose($hand); return $get; }else{ return false; } } ?>
|
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
微信支付
支付宝