脚本宝典收集整理的这篇文章主要介绍了最少的内存密集的方式来读取PHP中的文件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
而且,存储的行的长度是可变的.
PRivate static function readscoreFile($scoreFile) { $file = file($scoreFile); $relations = array(); for($i = 1; $i < count($file); $i++) { $relation = explode("\t",trim($file[$i])); $relation = array( 'pwId_1' => $relation[0],'pwId_2' => $relation[1],'score' => $relation[2],); if($relation['score'] > 0) { $relations[] = $relation; } } unset($file); return $relations; }
fopen
,fread
和
fclose
顺序读取文件:
$handle = foPEn($filename,'r'); if ($handle) { while (!feof($handle)) { echo fread($handle,8192); } fclose($handle); }
以上是脚本宝典为你收集整理的最少的内存密集的方式来读取PHP中的文件全部内容,希望文章能够帮你解决最少的内存密集的方式来读取PHP中的文件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。