我在php中写查询,查到个人的email,想把它导入到txt中,请问哪位高人有例子共享下,谢谢

解决方案 »

  1.   

    取出来,拼凑成串,然后用file_put_contents()函数写入文件.
      

  2.   

    这种问题,Google一下,你就知道。
      

  3.   

    <?php
    function get_emailaddress(){
        return "[email protected]" ;
    }function save_emailaddress($email) {
        $fp = fopen('email.txt','a+');
        if(!$fp) return ;
        fputs($fp,$email."\r\n");
        fclose($fp);
    }
    //生成email
    $email = get_emailaddress();
    //写email到文件
    save_emailaddress($email);
    ?>楼主好歹也是三颗星
      

  4.   

    当然是用最通用的CSV格式...
    <?php$list = array (
        'aaa,bbb,ccc,dddd',
        '123,456,789',
        '"aaa","bbb"'
    );$fp = fopen('file.csv', 'w');foreach ($list as $line) {
        fputcsv($fp, split(',', $line));
    }fclose($fp);
    ?> 
    PHP Manual
      

  5.   

    $file_ending = "txt";
    header("Content-Type: application/$file_type");
    header("Accept-Ranges:   bytes");    
    header("Content-Disposition: attachment; filename=$dbTablename.$file_ending");
    header("Pragma: no-cache");
    header("Expires: 0");.
    .
    .
    .
    .
    .
    .
      

  6.   

    $file_ending = "txt";
    header("Content-Type: application/$file_type");
    header("Accept-Ranges:   bytes");    
    header("Content-Disposition: attachment; filename=$dbTablename.$file_ending");
    header("Pragma: no-cache");
    header("Expires: 0");.
    .
    .
    .
    .
    .
    .