解决方案 »

  1.   

    file.txtguuk 武装部
    guwv 一部分
    guww 残疾人
    guxa 开门红
    guyk 下意识
    guyw 下半夜
    gvav 一刀切
    a.php$file = file_get_contents('file.txt');
    $content = explode("\n", $file);
    $url = 'http://localhost/result.php'; // 这里需用http$result = array();echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">';foreach($content as $row){
        $t = postdata($url, $row);
        $result[] = array('row'=>$row, 'posttime'=>$t);
        // 提示
        if($t){
            echo 'post data success<br>';
        }else{
            echo 'post data error';
        }
    }print_r($result);function postdata($url, $data){    $pdata = array(
            'text' => $data        
        );    $opts = array(
            'http' => array(
                'method' => 'POST',
                'header' => 'content-type:application/x-www-form-urlencoded',
                'content' => http_build_query($pdata)
            )    
        );    $context = stream_context_create($opts);    $result = file_get_contents($url, false, $context);    return $result;
    }
    result.php$row = isset($_POST['text'])? $_POST['text'] : '';if($row){
        echo date('Y-m-d H:i:s');
    }else{
        echo 'error';
    }
      

  2.   

    运行时间:
    Array
    (
        [0] => Array
            (
                [row] => guuk 武装部
                [posttime] => 2014-06-12 17:27:08
            )    [1] => Array
            (
                [row] => guwv 一部分
                [posttime] => 2014-06-12 17:27:08
            )    [2] => Array
            (
                [row] => guww 残疾人
                [posttime] => 2014-06-12 17:27:08
            )    [3] => Array
            (
                [row] => guxa 开门红
                [posttime] => 2014-06-12 17:27:08
            )    [4] => Array
            (
                [row] => guyk 下意识
                [posttime] => 2014-06-12 17:27:08
            )    [5] => Array
            (
                [row] => guyw 下半夜
                [posttime] => 2014-06-12 17:27:08
            )    [6] => Array
            (
                [row] => gvav 一刀切
                [posttime] => 2014-06-12 17:27:08
            ))