【发布时间】:2015-01-08 08:39:30
【问题描述】:
我希望 PHP 像这样读取我的文章文本文件。
示例文本文件:
OMG! Where is my right hand.
I try to find my right hand but I can't see it.
please tell me how to find it.
现在我有了这个功能代码
function getContent($file_path,$path=''){
$file_path = $file_path;
if(file_exists('./'.$file_path)){
$f_read = fopen($path.$file_path,'r');
$rs = "";
while (!feof($f_read)) {
$rs .= fread($f_read, 8192);
}
fclose($f_read);
}
else{
echo $rs = "Not Connect File !";
}
return($rs);
}
使用该代码后:
OMG! Where is my right hand. I try to find my right hand but I can't see it. please tell me how to find it.
我想使用 PHP 函数读取第一行到 string1,第一行之后是 string2 像这样
$string1 = "OMG! Where is my right hand."
$string2 = "I try to find my right hand but I can't see it.
please tell me how to find it."
请帮帮我:)
【问题讨论】:
-
回答者:请阅读问题。 OP 想要将第一行读入 $string1 并将文件的其余部分读入 $string2 - 你似乎没有解决那个 8 并且他为什么会被否决?)