if (@is_uploaded_file($_FILES['upfile']['tmp_name'])){
$f = $_FILES["upfile"];
$name = $f['name'];
$type = $f['type'];
$error = $f['error'];
$tmp = $f['tmp_name'];
$size = $f['size'];
if($error==0){
move_uploaded_file($tmp,"./$name");
echo '上传成功!
';
$Read_file = Read_it($name);
foreach($Read_file as $v){
$a = explode("\n",$v);
echo $a[0]."$".@$a[1]."
";
}
}
}
//read file
function Read_it($files){
if (file_exists($files)){
$file = file_get_contents($files);
$file = explode("*",trim($file));
return $file;
} else {
echo "The file named ".$filename."can not find.";
}
}
//read end
?>
效果实现了,具体你自己修改下
用php 代码上传一个txt文件,在页面里面输出内容
上传一个txt文件包含如下信息
* tension
There's an indefinable air of tension at the meeting.
The tension in the Far East is building up again.
* reputation
She had a reputation for punctuality.
This restaurant has a fine reputation.
页面输出
tension$There's an indefinable air of tension at the meeting.
reputation$She had a reputation for punctuality.
PS。思路应该是先用“*”分割内容。然后在采集第一行的单词,及此单词下的第一句句子。
淘宝API怎么链接啊?php的SDK怎么连接并调取测试呢?