• 技术文章 >php教程 >php手册

    php 文件操作

    2016-06-13 10:55:57原创814
    print?ini_set('memory_limit', '-1'); //
    ini_set("max_execution_time", "3600"); //设置超时时间

    $filep='qq.txt';


    $str=file('qq.txt');
    $lineCount = 0;
    foreach( $str AS $line ) {
    $line = str_replace( "\t", " ", $line );
    $tr = trim( $line );
    if ( preg_match( "/\\*|^\*|^ {1,}\*|\/\*|\*\/|^ {1,}\/\/|^\/\//", $line ) || $tr === "" ) {
    continue;
    }
    $lineCount++;

    $line = str_replace( "\r", "", $line );
    $line = str_replace( "\n", "", $line );
    if($lineCount<5){
    is_m('5.txt',"".$line."@qq.com\n");
    continue;
    }elseif ($lineCount <10){
    is_m('10.txt',"".$line."@qq.com\n");
    break;
    }


    }



    function is_m($filename,$c){
    $handle = fopen($filename, "a");
    if ($handle) {
    fwrite($handle, $c );
    fclose($handle);
    } }
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:phpcms v9 模板标签说明整理系列 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • 利用PHP实现智能文件类型检测的实现代码• 建立文件交换功能的脚本(二)• PHP教程.应用实例2 • 通过缓存数据库结果提高PHP性能• 对MVC的理解,MVC理解
    1/1

    PHP中文网